Beispiel #1
0
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"
Beispiel #2
0
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"
Beispiel #3
0
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"
Beispiel #4
0
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"
Beispiel #5
0
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"
Beispiel #6
0
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"
Beispiel #7
0
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"
Beispiel #8
0
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"
Beispiel #9
0
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"
Beispiel #10
0
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"
Beispiel #11
0
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"
Beispiel #12
0
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"