aboutsummaryrefslogtreecommitdiffstats
path: root/python_moondb/tests/unit_python/policies/mock_data.py
diff options
context:
space:
mode:
authorahmed.helmy <ahmad.helmy@orange.com>2017-12-26 13:26:17 +0200
committerahmed.helmy <ahmad.helmy@orange.com>2017-12-26 13:26:17 +0200
commit1b1e0d77ac23476a2d5bea1d63388402b768cc1e (patch)
treec8a5a2166ec5002cfbcfa6506f8f9987d264a4e3 /python_moondb/tests/unit_python/policies/mock_data.py
parent19a69441bbcc8b5e9e334f81c66d0f3720405fdd (diff)
add unit test for policy module
Change-Id: I981d9161cbdc167c4c9b5483d23842bca7e82006 Signed-off-by: ahmed.helmy <ahmad.helmy@orange.com>
Diffstat (limited to 'python_moondb/tests/unit_python/policies/mock_data.py')
-rw-r--r--python_moondb/tests/unit_python/policies/mock_data.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/python_moondb/tests/unit_python/policies/mock_data.py b/python_moondb/tests/unit_python/policies/mock_data.py
new file mode 100644
index 00000000..b2642979
--- /dev/null
+++ b/python_moondb/tests/unit_python/policies/mock_data.py
@@ -0,0 +1,45 @@
+def create_meta_rule():
+ meta_rule_value = {
+ "name": "meta_rule1",
+ "algorithm": "name of the meta rule algorithm",
+ "subject_categories": ["subject_category_id1",
+ "subject_category_id2"],
+ "object_categories": ["object_category_id1"],
+ "action_categories": ["action_category_id1"]
+ }
+ return meta_rule_value
+
+
+def create_model(meta_rule_id):
+ value = {
+ "name": "test_model",
+ "description": "test",
+ "meta_rules": [meta_rule_id]
+
+ }
+ return value
+
+
+def create_policy(model_id):
+ value = {
+ "name": "policy_1",
+ "model_id": model_id,
+ "genre": "authz",
+ "description": "test",
+ }
+ return value
+
+
+def get_policy_id():
+ import policies.test_policies as test_policies
+ import models.test_models as test_models
+ import models.test_meta_rules as test_meta_rules
+ meta_rule = test_meta_rules.add_meta_rule(value=create_meta_rule())
+ meta_rule_id = list(meta_rule.keys())[0]
+ model = test_models.add_model(value=create_model(meta_rule_id))
+ model_id = list(model.keys())[0]
+ value = create_policy(model_id)
+ policy = test_policies.add_policies(value)
+ assert policy
+ policy_id = list(policy.keys())[0]
+ return policy_id