コード例 #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')