def test_create_nohash(ns_resource, subcall_cmd, monkeypatch): def get(*args): return None monkeypatch.setattr("kpm.kubernetes.Kubernetes.get", get) k = Kubernetes(body=ns_resource['body']) assert k.create() == "created"
def test_create_force_protected(ns_resource, subcall_cmd, monkeypatch): def get(*args): svc2 = json.loads(ns_resource['body']) return svc2 monkeypatch.setattr("kpm.kubernetes.Kubernetes.get", get) k = Kubernetes(body=ns_resource['body']) assert k.create(force=True) == "protected"
def test_create_ok(svc_resource, subcall_cmd, monkeypatch): def get(*args): svc2 = json.loads(svc_resource['body']) return svc2 monkeypatch.setattr("kpm.kubernetes.Kubernetes.get", get) k = Kubernetes(body=svc_resource['body']) assert k.create() == "ok"
def test_create_ok_nohash(ns_resource, subcall_cmd, monkeypatch): def get(*args): r = json.loads(ns_resource['body']) return r monkeypatch.setattr("kpm.kubernetes.Kubernetes.get", get) k = Kubernetes(body=ns_resource['body']) assert k.create() == "ok"
def test_create_update(svc_resource, subcall_cmd, monkeypatch): def get(*args): svc2 = json.loads(svc_resource['body']) svc2['metadata']['annotations']['kpm.hash'] = 'dummy' return svc2 monkeypatch.setattr("kpm.kubernetes.Kubernetes.get", get) k = Kubernetes(body=svc_resource['body']) assert k.create() == "updated"
def test_create_proxy(svc_resource): proxy = "http://localhost:8001" k = Kubernetes(body=svc_resource['body'], proxy=proxy, endpoint=svc_resource['endpoint']) url = "%s/%s" % (proxy, svc_resource['endpoint'][1:-1]) url2 = "%s/%s" % (k.proxy.geturl(), k.endpoint) assert url == url2 with requests_mock.mock() as m: response = get_response(svc_resource["name"], svc_resource["kind"]) m.post(url, text=response) m.get(url + "/" + svc_resource['name'], status_code=404) assert k.create() == "created"