diff options
author | mohamedasem <mmagraby.ext@orange.com> | 2018-04-12 14:56:54 +0200 |
---|---|---|
committer | mohamedasem <mmagraby.ext@orange.com> | 2018-04-12 14:56:54 +0200 |
commit | b7de0a61dea9b7ac3b411f813dacc24f45d58d85 (patch) | |
tree | 44023d1ab2e5c6ca50b0336cb8418d2b3fbdd436 /python_moondb/tests/unit_python/models | |
parent | 814b34aee2b42bc52229e3dad37e95bf480cddfe (diff) |
add_test_cases_to_test_categories
Change-Id: Ie8e2876770d8e8edcd8fe1b8476fe7ad79a2fa72
Signed-off-by: mohamedasem <mmagraby.ext@orange.com>
Diffstat (limited to 'python_moondb/tests/unit_python/models')
-rw-r--r-- | python_moondb/tests/unit_python/models/test_categories.py | 66 |
1 files changed, 63 insertions, 3 deletions
diff --git a/python_moondb/tests/unit_python/models/test_categories.py b/python_moondb/tests/unit_python/models/test_categories.py index 111538b4..0ffcf96e 100644 --- a/python_moondb/tests/unit_python/models/test_categories.py +++ b/python_moondb/tests/unit_python/models/test_categories.py @@ -13,9 +13,29 @@ 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_id = list(category.keys())[0] assert category is not None with pytest.raises(SubjectCategoryExisting): - add_subject_category(value={"name":"category name", "description":"description 2"}) + add_subject_category(category_id, value={"name":"category name", "description":"description 2"}) + + +def get_subject_category(cat_id=None): + from python_moondb.core import ModelManager + category = ModelManager.get_subject_categories(user_id=None, category_id=cat_id) + return category + + +def test_get_subject_categories(): + 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 + + +def test_get_subject_categories_with_invalid_id(): + category_id = "invalid_id" + subject_category = get_subject_category(category_id) + assert len(subject_category) == 0 def add_object_category(cat_id=None, value=None): @@ -26,9 +46,29 @@ 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_id = list(category.keys())[0] assert category is not None with pytest.raises(ObjectCategoryExisting): - add_object_category(value={"name":"category name", "description":"description 2"}) + add_object_category(category_id, value={"name":"category name", "description":"description 2"}) + + +def get_object_category(cat_id=None): + from python_moondb.core import ModelManager + category = ModelManager.get_object_categories(user_id=None, category_id=cat_id) + return category + + +def test_get_object_categories(): + 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 + + +def test_get_object_categories_with_invalid_id(): + category_id = "invalid_id" + object_category = get_object_category(category_id) + assert len(object_category) == 0 def add_action_category(cat_id=None, value=None): @@ -39,6 +79,26 @@ 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_id = list(category.keys())[0] assert category is not None with pytest.raises(ActionCategoryExisting): - add_action_category(value={"name":"category name", "description":"description 2"}) + add_action_category(category_id, value={"name":"category name", "description":"description 2"}) + + +def get_action_category(cat_id=None): + from python_moondb.core import ModelManager + category = ModelManager.get_action_categories(user_id=None, category_id=cat_id) + return category + + +def test_get_action_categories(): + 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 + + +def test_get_action_categories_with_invalid_id(): + category_id = "invalid_id" + action_category = get_action_category(category_id) + assert len(action_category) == 0
\ No newline at end of file |