diff options
author | francois.cellier <francois.cellier@orange.com> | 2018-03-16 15:51:01 +0100 |
---|---|---|
committer | Thomas Duval <thomas.duval@orange.com> | 2018-03-22 17:22:31 +0100 |
commit | 9ac76616f62ef73f093ce63017782dda6bd3fc9d (patch) | |
tree | 57cf872e020268ec78f048ab53b0cf83da8bbb69 /python_moondb/tests/unit_python/models/test_categories.py | |
parent | 6d2dbd0af7da445b39bbb7e16a36260268c685cd (diff) |
Add unique constraints on db tables
Change-Id: I8480ed2be16f73ada314f64f0bfda8e788288933
Diffstat (limited to 'python_moondb/tests/unit_python/models/test_categories.py')
-rw-r--r-- | python_moondb/tests/unit_python/models/test_categories.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/python_moondb/tests/unit_python/models/test_categories.py b/python_moondb/tests/unit_python/models/test_categories.py new file mode 100644 index 00000000..111538b4 --- /dev/null +++ b/python_moondb/tests/unit_python/models/test_categories.py @@ -0,0 +1,44 @@ +import pytest +import logging +from python_moonutilities.exceptions import * + +logger = logging.getLogger("moon.db.tests.models.test_categories") + + +def add_subject_category(cat_id=None, value=None): + from python_moondb.core import ModelManager + category = ModelManager.add_subject_category(user_id=None, category_id=cat_id, value=value) + return category + + +def test_add_subject_category_twice(): + category = add_subject_category(value={"name":"category name", "description":"description 1"}) + assert category is not None + with pytest.raises(SubjectCategoryExisting): + add_subject_category(value={"name":"category name", "description":"description 2"}) + + +def add_object_category(cat_id=None, value=None): + from python_moondb.core import ModelManager + category = ModelManager.add_object_category(user_id=None, category_id=cat_id, value=value) + return category + + +def test_add_object_category_twice(): + category = add_object_category(value={"name":"category name", "description":"description 1"}) + assert category is not None + with pytest.raises(ObjectCategoryExisting): + add_object_category(value={"name":"category name", "description":"description 2"}) + + +def add_action_category(cat_id=None, value=None): + from python_moondb.core import ModelManager + category = ModelManager.add_action_category(user_id=None, category_id=cat_id, value=value) + return category + + +def test_add_action_category_twice(): + category = add_action_category(value={"name":"category name", "description":"description 1"}) + assert category is not None + with pytest.raises(ActionCategoryExisting): + add_action_category(value={"name":"category name", "description":"description 2"}) |