aboutsummaryrefslogtreecommitdiffstats
path: root/python_moondb/tests/unit_python/policies/test_assignments.py
diff options
context:
space:
mode:
Diffstat (limited to 'python_moondb/tests/unit_python/policies/test_assignments.py')
-rwxr-xr-xpython_moondb/tests/unit_python/policies/test_assignments.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/python_moondb/tests/unit_python/policies/test_assignments.py b/python_moondb/tests/unit_python/policies/test_assignments.py
index 675c2ff9..24a3a7b0 100755
--- a/python_moondb/tests/unit_python/policies/test_assignments.py
+++ b/python_moondb/tests/unit_python/policies/test_assignments.py
@@ -19,7 +19,8 @@ def test_get_action_assignments(db):
data_id = mock_data.create_action_data(policy_id=policy_id, category_id=action_category_id)
assignment_helper.add_action_assignment(policy_id, action_id, action_category_id, data_id)
- act_assignments = assignment_helper.get_action_assignments(policy_id, action_id, action_category_id)
+ act_assignments = assignment_helper.get_action_assignments(policy_id, action_id,
+ action_category_id)
action_id_1 = list(act_assignments.keys())[0]
assert act_assignments[action_id_1]["policy_id"] == policy_id
assert act_assignments[action_id_1]["action_id"] == action_id
@@ -36,7 +37,8 @@ def test_add_action_assignments(db):
meta_rule_name="meta_rule_1")
action_id = mock_data.create_action(policy_id)
data_id = mock_data.create_action_data(policy_id=policy_id, category_id=action_category_id)
- action_assignments = assignment_helper.add_action_assignment(policy_id, action_id, action_category_id, data_id)
+ action_assignments = assignment_helper.add_action_assignment(policy_id, action_id,
+ action_category_id, data_id)
assert action_assignments
action_id_1 = list(action_assignments.keys())[0]
assert action_assignments[action_id_1]["policy_id"] == policy_id
@@ -47,6 +49,8 @@ def test_add_action_assignments(db):
with pytest.raises(ActionAssignmentExisting) as exception_info:
assignment_helper.add_action_assignment(policy_id, action_id, action_category_id, data_id)
+ assert str(exception_info.value) == '409: Action Assignment Existing'
+ assert str(exception_info.value.description) == 'The given action assignment value is existing.'
def test_delete_action_assignment(db):
@@ -79,7 +83,8 @@ def test_get_object_assignments(db):
object_id = mock_data.create_object(policy_id)
data_id = mock_data.create_object_data(policy_id=policy_id, category_id=object_category_id)
assignment_helper.add_object_assignment(policy_id, object_id, object_category_id, data_id)
- obj_assignments = assignment_helper.get_object_assignments(policy_id, object_id, object_category_id)
+ obj_assignments = assignment_helper.get_object_assignments(policy_id, object_id,
+ object_category_id)
object_id_1 = list(obj_assignments.keys())[0]
assert obj_assignments[object_id_1]["policy_id"] == policy_id
assert obj_assignments[object_id_1]["object_id"] == object_id
@@ -109,7 +114,8 @@ def test_add_object_assignments(db):
meta_rule_name="meta_rule_1")
object_id = mock_data.create_object(policy_id)
data_id = mock_data.create_object_data(policy_id=policy_id, category_id=object_category_id)
- object_assignments = assignment_helper.add_object_assignment(policy_id, object_id, object_category_id, data_id)
+ object_assignments = assignment_helper.add_object_assignment(policy_id, object_id,
+ object_category_id, data_id)
assert object_assignments
object_id_1 = list(object_assignments.keys())[0]
assert object_assignments[object_id_1]["policy_id"] == policy_id
@@ -118,8 +124,10 @@ def test_add_object_assignments(db):
assert len(object_assignments[object_id_1].get("assignments")) == 1
assert data_id in object_assignments[object_id_1].get("assignments")
- with pytest.raises(ObjectAssignmentExisting):
+ with pytest.raises(ObjectAssignmentExisting) as exception_info:
assignment_helper.add_object_assignment(policy_id, object_id, object_category_id, data_id)
+ assert str(exception_info.value) == '409: Object Assignment Existing'
+ assert str(exception_info.value.description) == 'The given object assignment value is existing.'
def test_delete_object_assignment(db):
@@ -132,7 +140,8 @@ def test_delete_object_assignment(db):
data_id = mock_data.create_object_data(policy_id=policy_id, category_id=object_category_id)
assignment_helper.add_object_assignment(policy_id, object_id, object_category_id, data_id)
- assignment_helper.delete_object_assignment(policy_id, object_id, object_category_id, data_id=data_id)
+ assignment_helper.delete_object_assignment(policy_id, object_id, object_category_id,
+ data_id=data_id)
assignments = assignment_helper.get_object_assignments(policy_id)
assert len(assignments) == 0
@@ -154,7 +163,8 @@ def test_get_subject_assignments(db):
data_id = mock_data.create_subject_data(policy_id=policy_id, category_id=subject_category_id)
assignment_helper.add_subject_assignment(policy_id, subject_id, subject_category_id, data_id)
- subj_assignments = assignment_helper.get_subject_assignments(policy_id, subject_id, subject_category_id)
+ subj_assignments = assignment_helper.get_subject_assignments(policy_id, subject_id,
+ subject_category_id)
subject_id_1 = list(subj_assignments.keys())[0]
assert subj_assignments[subject_id_1]["policy_id"] == policy_id
assert subj_assignments[subject_id_1]["subject_id"] == subject_id
@@ -186,7 +196,8 @@ def test_add_subject_assignments(db):
subject_id = mock_data.create_subject(policy_id)
data_id = mock_data.create_subject_data(policy_id=policy_id, category_id=subject_category_id)
- subject_assignments = assignment_helper.add_subject_assignment(policy_id, subject_id, subject_category_id, data_id)
+ subject_assignments = assignment_helper.add_subject_assignment(policy_id, subject_id,
+ subject_category_id, data_id)
assert subject_assignments
subject_id_1 = list(subject_assignments.keys())[0]
assert subject_assignments[subject_id_1]["policy_id"] == policy_id
@@ -195,8 +206,12 @@ def test_add_subject_assignments(db):
assert len(subject_assignments[subject_id_1].get("assignments")) == 1
assert data_id in subject_assignments[subject_id_1].get("assignments")
- with pytest.raises(SubjectAssignmentExisting):
- assignment_helper.add_subject_assignment(policy_id, subject_id, subject_category_id, data_id)
+ with pytest.raises(SubjectAssignmentExisting) as exception_info:
+ assignment_helper.add_subject_assignment(policy_id, subject_id, subject_category_id,
+ data_id)
+ assert str(exception_info.value) == '409: Subject Assignment Existing'
+ assert str(
+ exception_info.value.description) == 'The given subject assignment value is existing.'
def test_delete_subject_assignment(db):