예제 #1
0
파일: test_vault.py 프로젝트: b10n1k/pcw
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')
예제 #2
0
파일: test_vault.py 프로젝트: b10n1k/pcw
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')