def test_get_proxy_500_raise(svc_resource): proxy = "http://localhost:8001" k = Kubernetes(body=svc_resource['body'], proxy=proxy, endpoint=svc_resource['endpoint']) url = "%s/%s/%s" % (proxy, svc_resource['endpoint'][1:-1], svc_resource['name']) with requests_mock.mock() as m: response = get_response(svc_resource["name"], svc_resource["kind"]) m.get(url, text=response, status_code=500) with pytest.raises(requests.exceptions.HTTPError): k.get()
def test_get_proxy_500_raise(svc_resource): proxy = "http://localhost:8001" k = Kubernetes(body=svc_resource['body'], proxy=proxy, endpoint=svc_resource['endpoint']) url = "%s/%s/%s" % (proxy, svc_resource['endpoint'][1:-1], svc_resource['name']) with requests_mock.mock() as m: response = get_response(svc_resource["name"], svc_resource["kind"]) m.get(url, text=response, status_code=500) with pytest.raises(requests.exceptions.HTTPError): k.get()
def test_get_proxy_404(svc_resource): proxy = "http://localhost:8001" k = Kubernetes(body=svc_resource['body'], proxy=proxy, endpoint=svc_resource['endpoint']) url = "%s/%s/%s" % (proxy, svc_resource['endpoint'][1:-1], svc_resource['name']) with requests_mock.mock() as m: response = get_response(svc_resource["name"], svc_resource["kind"]) m.get(url, text=response, status_code=404) assert k.get() is None
def test_get_proxy(svc_resource): proxy = "http://localhost:8001" k = Kubernetes(body=svc_resource['body'], proxy=proxy, endpoint=svc_resource['endpoint']) url = "%s/%s/%s" % (proxy, svc_resource['endpoint'][1:-1], svc_resource['name']) url2 = "%s/%s/%s" % (k.proxy.geturl(), k.endpoint, k.name) assert url == url2 with requests_mock.mock() as m: response = get_response(svc_resource["name"], svc_resource["kind"]) m.get(url, text=response) assert json.dumps(k.get()) == json.dumps(json.loads(response))
def test_get_proxy_404(svc_resource): proxy = "http://localhost:8001" k = Kubernetes(body=svc_resource['body'], proxy=proxy, endpoint=svc_resource['endpoint']) url = "%s/%s/%s" % (proxy, svc_resource['endpoint'][1:-1], svc_resource['name']) with requests_mock.mock() as m: response = get_response(svc_resource["name"], svc_resource["kind"]) m.get(url, text=response, status_code=404) assert k.get() is None
def test_get_proxy(svc_resource): proxy = "http://localhost:8001" k = Kubernetes(body=svc_resource['body'], proxy=proxy, endpoint=svc_resource['endpoint']) url = "%s/%s/%s" % (proxy, svc_resource['endpoint'][1:-1], svc_resource['name']) url2 = "%s/%s/%s" % (k.proxy.geturl(), k.endpoint, k.name) assert url == url2 with requests_mock.mock() as m: response = get_response(svc_resource["name"], svc_resource["kind"]) m.get(url, text=response) assert json.dumps(k.get()) == json.dumps(json.loads(response))
def test_get_svc(subcall_get_assert, svc_resource): k = Kubernetes(body=svc_resource['body']) assert json.dumps(k.get()) == json.dumps( json.loads(get_response(k.name, k.kind)))
def test_get_cmd_error(svc_resource, subcall_cmd_error): k = Kubernetes(body=svc_resource['body']) assert k.get() is None
def test_get_ns(subcall_get_assert, ns_resource): k = Kubernetes(body=ns_resource['body'], namespace="testns") assert json.dumps(k.get()) == json.dumps( json.loads(get_response(k.name, k.kind)))
def test_get_svc(subcall_get_assert, svc_resource): k = Kubernetes(body=svc_resource['body']) assert json.dumps(k.get()) == json.dumps(json.loads(get_response(k.name, k.kind)))
def test_get_cmd_error(svc_resource, subcall_cmd_error): k = Kubernetes(body=svc_resource['body']) assert k.get() is None
def test_get_ns(subcall_get_assert, ns_resource): k = Kubernetes(body=ns_resource['body'], namespace="testns") assert json.dumps(k.get()) == json.dumps(json.loads(get_response(k.name, k.kind)))