diff options
author | ahmed.helmy <ahmad.helmy@orange.com> | 2017-12-26 13:33:38 +0200 |
---|---|---|
committer | ahmed.helmy <ahmad.helmy@orange.com> | 2017-12-26 13:33:38 +0200 |
commit | c7102ef6b23ea0764e58fa02c3b954629c5c83fa (patch) | |
tree | 7fc91474f4f87371ad98b547de3edf1282e1e5e1 | |
parent | 19a69441bbcc8b5e9e334f81c66d0f3720405fdd (diff) |
add unit test for pdp module
Change-Id: I1aadbb836694212a2de52a81b9b637be856e0867
Signed-off-by: ahmed.helmy <ahmad.helmy@orange.com>
-rwxr-xr-x | python_moondb/tests/unit_python/test_pdp.py | 69 |
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 |