aboutsummaryrefslogtreecommitdiffstats
path: root/moon_orchestrator/tests/unit_python
diff options
context:
space:
mode:
authorReemMahmoud <rfawzy.ext@orange.com>2018-01-11 14:05:25 +0200
committerReemMahmoud <rfawzy.ext@orange.com>2018-01-11 14:05:25 +0200
commit74fcfbdbd545bbff2b3ab5a03f68ad9cf078fab4 (patch)
treef28ec0ef632e1e065cd3d847316d8213ce6ccce2 /moon_orchestrator/tests/unit_python
parent0129d960d4c39d96e775674264c06908e121b7ed (diff)
Add tests to moon_orchestrator and refactor
Change-Id: I666e9c0e89daeb32896169a62c0872719ee04cc8 Signed-off-by: ReemMahmoud <rfawzy.ext@orange.com>
Diffstat (limited to 'moon_orchestrator/tests/unit_python')
-rw-r--r--moon_orchestrator/tests/unit_python/test_pods.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/moon_orchestrator/tests/unit_python/test_pods.py b/moon_orchestrator/tests/unit_python/test_pods.py
index 0a5a5ba5..f760aa62 100644
--- a/moon_orchestrator/tests/unit_python/test_pods.py
+++ b/moon_orchestrator/tests/unit_python/test_pods.py
@@ -17,6 +17,20 @@ def test_get_pods(context, monkeypatch):
assert "pods" in data
+def test_get_pods_failure(context, monkeypatch):
+ patch_k8s(monkeypatch)
+
+ import moon_orchestrator.server
+ server = moon_orchestrator.server.create_server()
+ _client = server.app.test_client()
+ req = _client.get("/pods/invalid")
+ assert req.status_code == 200
+ assert req.data
+ data = get_json(req.data)
+ assert isinstance(data, dict)
+ assert not data["pods"]
+
+
def test_add_pods(context, monkeypatch):
patch_k8s(monkeypatch)
@@ -38,6 +52,40 @@ def test_add_pods(context, monkeypatch):
assert data["pods"]
+def test_add_pods_with_no_data(context, monkeypatch):
+ patch_k8s(monkeypatch)
+ import moon_orchestrator.server
+ server = moon_orchestrator.server.create_server()
+ _client = server.app.test_client()
+ req = _client.post("/pods", data=json.dumps({}),
+ headers={'Content-Type': 'application/json'})
+ assert req.status_code == 500
+ assert req.data
+ data = get_json(req.data)
+ assert '400: Policy Unknown' in data['message']
+
+
+def test_add_pods_with_no_policies_no_models(context, monkeypatch, no_requests):
+ patch_k8s(monkeypatch)
+
+ import moon_orchestrator.server
+ server = moon_orchestrator.server.create_server()
+ _client = server.app.test_client()
+ no_requests.get("http://manager:8082/policies",
+ json={'policies': {}})
+
+ no_requests.get("http://manager:8082/models",
+ json={'models': {}})
+ data = {
+ "keystone_project_id": context.get('project_id'),
+ "pdp_id": context.get('pdp_id'),
+ "security_pipeline": context.get('security_pipeline'),
+ }
+ req = _client.post("/pods", data=json.dumps(data),
+ headers={'Content-Type': 'application/json'})
+ assert req.status_code == 200
+
+
def test_delete_pods(context, monkeypatch):
# TODO
pass