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/policies/test_policies.py | |
parent | 6d2dbd0af7da445b39bbb7e16a36260268c685cd (diff) |
Add unique constraints on db tables
Change-Id: I8480ed2be16f73ada314f64f0bfda8e788288933
Diffstat (limited to 'python_moondb/tests/unit_python/policies/test_policies.py')
-rwxr-xr-x | python_moondb/tests/unit_python/policies/test_policies.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/python_moondb/tests/unit_python/policies/test_policies.py b/python_moondb/tests/unit_python/policies/test_policies.py index 148034ef..f81f0d39 100755 --- a/python_moondb/tests/unit_python/policies/test_policies.py +++ b/python_moondb/tests/unit_python/policies/test_policies.py @@ -5,7 +5,7 @@ import pytest import policies.mock_data as mock_data - +from python_moonutilities.exceptions import * def get_policies(): from python_moondb.core import PolicyManager @@ -97,9 +97,9 @@ def test_add_policies_twice_with_same_id(db): "description": "test", } add_policies(policy_id, value) - with pytest.raises(Exception) as exception_info: + with pytest.raises(PolicyExisting) as exception_info: add_policies(policy_id, value) - assert str(exception_info.value) == '409: Policy Error' + #assert str(exception_info.value) == '409: Policy Error' def test_delete_policies(db): @@ -127,9 +127,9 @@ def test_delete_policies(db): def test_delete_policies_with_invalid_id(db): policy_id = 'policy_id_1' - with pytest.raises(Exception) as exception_info: + with pytest.raises(PolicyUnknown) as exception_info: delete_policies(policy_id) - assert str(exception_info.value) == '400: Policy Unknown' + #assert str(exception_info.value) == '400: Policy Unknown' def test_update_policy(db): @@ -156,9 +156,9 @@ def test_update_policy_with_invalid_id(db): "genre": "authz", "description": "test-3", } - with pytest.raises(Exception) as exception_info: + with pytest.raises(PolicyUnknown) as exception_info: update_policy(policy_id, value) - assert str(exception_info.value) == '400: Policy Unknown' + #assert str(exception_info.value) == '400: Policy Unknown' def test_get_policy_from_meta_rules(db): @@ -271,6 +271,9 @@ def test_add_rule(db): assert key in rules[rule_id] assert rules[rule_id][key] == value[key] + with pytest.raises(RuleExisting): + add_rule(policy_id, meta_rule_id, value) + def test_delete_rule(db): value = { |