diff options
author | ReemMahmoud <rfawzy.ext@orange.com> | 2018-05-02 14:38:52 +0200 |
---|---|---|
committer | ReemMahmoud <rfawzy.ext@orange.com> | 2018-05-02 14:38:52 +0200 |
commit | f1d3e269b87bdbfa10997606c04916bc3f36edfb (patch) | |
tree | 7db1ad9b8a5ecf777ea42cf2ef957c8ad465d178 /python_moondb/tests/unit_python/models/test_categories.py | |
parent | 467351eaa204676d700f73cca6f359dd1723565c (diff) |
Add unique names test cases
Change-Id: I3f314ec3b3e88839c77a93ea016c10c0a31d10b1
Diffstat (limited to 'python_moondb/tests/unit_python/models/test_categories.py')
-rw-r--r-- | python_moondb/tests/unit_python/models/test_categories.py | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/python_moondb/tests/unit_python/models/test_categories.py b/python_moondb/tests/unit_python/models/test_categories.py index cdcf6bcb..8782f172 100644 --- a/python_moondb/tests/unit_python/models/test_categories.py +++ b/python_moondb/tests/unit_python/models/test_categories.py @@ -17,11 +17,18 @@ def add_subject_category(cat_id=None, value=None): def test_add_subject_category_twice(): - category = add_subject_category(value={"name":"category name", "description":"description 1"}) + category = add_subject_category(value={"name": "category name", "description": "description 1"}) category_id = list(category.keys())[0] assert category is not None with pytest.raises(SubjectCategoryExisting): - add_subject_category(category_id, value={"name":"category name", "description":"description 2"}) + add_subject_category(category_id, value={"name": "category name", "description": "description 2"}) + + +def test_add_subject_category_twice_with_same_name(): + 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 get_subject_category(cat_id=None): @@ -31,7 +38,7 @@ def get_subject_category(cat_id=None): def test_get_subject_categories(): - added_category = add_subject_category(value={"name":"category name", "description":"description 1"}) + added_category = add_subject_category(value={"name": "category name", "description": "description 1"}) category_id = list(added_category.keys())[0] subject_category = get_subject_category(category_id) assert subject_category == added_category @@ -99,11 +106,18 @@ def add_object_category(cat_id=None, value=None): def test_add_object_category_twice(): - category = add_object_category(value={"name":"category name", "description":"description 1"}) + category = add_object_category(value={"name": "category name", "description": "description 1"}) category_id = list(category.keys())[0] assert category is not None with pytest.raises(ObjectCategoryExisting): - add_object_category(category_id, value={"name":"category name", "description":"description 2"}) + add_object_category(category_id, value={"name": "category name", "description": "description 2"}) + + +def test_add_object_category_twice_with_same_name(): + 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 get_object_category(cat_id=None): @@ -113,7 +127,7 @@ def get_object_category(cat_id=None): def test_get_object_categories(): - added_category = add_object_category(value={"name":"category name", "description":"description 1"}) + added_category = add_object_category(value={"name": "category name", "description": "description 1"}) category_id = list(added_category.keys())[0] object_category = get_object_category(category_id) assert object_category == added_category @@ -181,11 +195,18 @@ def add_action_category(cat_id=None, value=None): def test_add_action_category_twice(): - category = add_action_category(value={"name":"category name", "description":"description 1"}) + category = add_action_category(value={"name": "category name", "description": "description 1"}) category_id = list(category.keys())[0] assert category is not None with pytest.raises(ActionCategoryExisting): - add_action_category(category_id, value={"name":"category name", "description":"description 2"}) + add_action_category(category_id, value={"name": "category name", "description": "description 2"}) + + +def test_add_action_category_twice_with_same_name(): + 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"}) def get_action_category(cat_id=None): @@ -195,7 +216,7 @@ def get_action_category(cat_id=None): def test_get_action_categories(): - added_category = add_action_category(value={"name":"category name", "description":"description 1"}) + added_category = add_action_category(value={"name": "category name", "description": "description 1"}) category_id = list(added_category.keys())[0] action_category = get_action_category(category_id) assert action_category == added_category |