aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuan HE <ruan.he@orange.com>2017-12-26 15:04:27 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-12-26 15:04:27 +0000
commit379f200e5a71e02b00f6a57b5c5bbb1470fa0ca0 (patch)
tree5d39b4ed7e8b0fe404c9c748e3027d5026db9069
parent11835452d085ed40f7d110427458430705c4980e (diff)
parentc7102ef6b23ea0764e58fa02c3b954629c5c83fa (diff)
Merge "add unit test for pdp module"
-rwxr-xr-xpython_moondb/tests/unit_python/test_pdp.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/python_moondb/tests/unit_python/test_pdp.py b/python_moondb/tests/unit_python/test_pdp.py
new file mode 100755
index 00000000..cb206d3d
--- /dev/null
+++ b/python_moondb/tests/unit_python/test_pdp.py
@@ -0,0 +1,69 @@
+def update_pdp(pdp_id, value):
+ from python_moondb.core import PDPManager
+ return PDPManager.update_pdp("", pdp_id, value)
+
+
+def delete_pdp(pdp_id):
+ from python_moondb.core import PDPManager
+ PDPManager.delete_pdp("", pdp_id)
+
+
+def add_pdp(pdp_id=None, value=None):
+ from python_moondb.core import PDPManager
+ return PDPManager.add_pdp("", pdp_id, value)
+
+
+def get_pdp(pdp_id=None):
+ from python_moondb.core import PDPManager
+ return PDPManager.get_pdp("", pdp_id)
+
+
+def test_update_pdp(db):
+ pdp_id = "pdp_id1"
+ value = {
+ "name": "test_pdp",
+ "security_pipeline": ["policy_id_1", "policy_id_2"],
+ "keystone_project_id": "keystone_project_id1",
+ "description": "...",
+ }
+ add_pdp(pdp_id, value)
+ pdp = update_pdp(pdp_id, value)
+ assert pdp
+
+
+def test_delete_pdp(db):
+ pdp_id = "pdp_id1"
+ value = {
+ "name": "test_pdp",
+ "security_pipeline": ["policy_id_1", "policy_id_2"],
+ "keystone_project_id": "keystone_project_id1",
+ "description": "...",
+ }
+ add_pdp(pdp_id, value)
+ delete_pdp(pdp_id)
+ assert len(get_pdp(pdp_id)) == 0
+
+
+def test_add_pdp(db):
+ pdp_id = "pdp_id1"
+ value = {
+ "name": "test_pdp",
+ "security_pipeline": ["policy_id_1", "policy_id_2"],
+ "keystone_project_id": "keystone_project_id1",
+ "description": "...",
+ }
+ pdp = add_pdp(pdp_id, value)
+ assert pdp
+
+
+def test_get_pdp(db):
+ pdp_id = "pdp_id1"
+ value = {
+ "name": "test_pdp",
+ "security_pipeline": ["policy_id_1", "policy_id_2"],
+ "keystone_project_id": "keystone_project_id1",
+ "description": "...",
+ }
+ add_pdp(pdp_id, value)
+ pdp = get_pdp(pdp_id)
+ assert len(pdp) == 1