def test_push_unauthorized(): r = CnrClient() with requests_mock.mock() as m: body = {"blob": "fdsfds"} response = b'{"packages": "true"}' m.post(DEFAULT_REGISTRY + DEFAULT_PREFIX + "/api/v1/packages/ant31/kube-ui?force=false", complete_qs=True, content=response, status_code=401) with pytest.raises(requests.HTTPError): r.push(name="ant31/kube-ui", body=body)
def test_push_force(): body = {"blob": b64encode(b"foobar").decode('utf-8')} r = CnrClient() response = '{"packages": "true"}' with requests_mock.mock() as m: m.post(DEFAULT_REGISTRY + DEFAULT_PREFIX + "/api/v1/packages/ant31/kube-ui?force=true", complete_qs=True, text=response) assert json.dumps(r.push(name="ant31/kube-ui", body=body, force=True)) == json.dumps( json.loads(response))