diff options
Diffstat (limited to 'moon_orchestrator/tests/unit_python')
-rw-r--r-- | moon_orchestrator/tests/unit_python/test_pods.py | 48 |
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 |