def test_http_response_with_json_error(monkeypatch): az = AzureCredential(namespace) monkeypatch.setattr( requests, "post", lambda *args, **kwargs: MockResponse( json_response={'errors': ['err1']})) with pytest.raises(ConnectionError): az.httpPost('foobar', data={}) monkeypatch.setattr( requests, "get", lambda *args, **kwargs: MockResponse( json_response={'errors': ['err1']})) with pytest.raises(ConnectionError): az.httpGet('foobar')
def test_http_response_no_json(monkeypatch): az = AzureCredential(namespace) monkeypatch.setattr( requests, "post", lambda *args, **kwargs: MockResponse(content_type='html/text')) with pytest.raises(ConnectionError): az.httpPost('foobar', data={}) monkeypatch.setattr( requests, "get", lambda *args, **kwargs: MockResponse(content_type='html/text')) with pytest.raises(ConnectionError): az.httpGet('foobar')