aboutsummaryrefslogtreecommitdiffstats
path: root/python_moondb/tests/unit_python/helpers/model_helper.py
diff options
context:
space:
mode:
authorThomas Duval <thomas.duval@orange.com>2018-06-19 16:13:31 +0200
committerThomas Duval <thomas.duval@orange.com>2018-06-19 16:30:55 +0200
commit2dbe655587ca98b67c1a3e3798c63fd47229adc0 (patch)
treedf374b5378225c9946ec0c97968bfa591fb9f9b6 /python_moondb/tests/unit_python/helpers/model_helper.py
parentd28f8e68ac176a15dbbd7873f757f5a9f221d118 (diff)
Update code to 4.5 official version
Change-Id: I5075da0e2a3247ae1564f21b358748f482b75aa4
Diffstat (limited to 'python_moondb/tests/unit_python/helpers/model_helper.py')
-rw-r--r--python_moondb/tests/unit_python/helpers/model_helper.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/python_moondb/tests/unit_python/helpers/model_helper.py b/python_moondb/tests/unit_python/helpers/model_helper.py
new file mode 100644
index 00000000..58946a99
--- /dev/null
+++ b/python_moondb/tests/unit_python/helpers/model_helper.py
@@ -0,0 +1,50 @@
+# Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
+# This software is distributed under the terms and conditions of the 'Apache-2.0'
+# license which can be found in the file 'LICENSE' in this package distribution
+# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
+
+from helpers import mock_data
+
+
+def get_models(model_id=None):
+ from python_moondb.core import ModelManager
+ return ModelManager.get_models(user_id=None, model_id=model_id)
+
+
+def add_model(model_id=None, value=None):
+ from python_moondb.core import ModelManager
+ if not value:
+ subject_category_id, object_category_id, action_category_id, meta_rule_id = mock_data.create_new_meta_rule(
+ subject_category_name="subject_category1",
+ object_category_name="object_category1",
+ action_category_name="action_category1")
+ name = "MLS" if model_id is None else "MLS " + model_id
+ value = {
+ "name": name,
+ "description": "test",
+ "meta_rules": [meta_rule_id]
+ }
+ return ModelManager.add_model(user_id=None, model_id=model_id, value=value)
+
+
+def delete_models(uuid=None, name=None):
+ from python_moondb.core import ModelManager
+ if not uuid:
+ for model_id, model_value in get_models():
+ if name == model_value['name']:
+ uuid = model_id
+ break
+ ModelManager.delete_model(user_id=None, model_id=uuid)
+
+
+def delete_all_models():
+ from python_moondb.core import ModelManager
+ models_values = get_models()
+ print(models_values)
+ for model_id, model_value in models_values.items():
+ ModelManager.delete_model(user_id=None, model_id=model_id)
+
+
+def update_model(model_id=None, value=None):
+ from python_moondb.core import ModelManager
+ return ModelManager.update_model(user_id=None, model_id=model_id, value=value)