Esempio n. 1
0
def test_get_failed_http_error(web_client: WebClient,
                               mocker: MockerFixture) -> None:
    """
    must suppress any exception happened during status getting
    """
    mocker.patch("requests.get", side_effect=requests.exceptions.HTTPError())
    assert web_client.get(None) == []
Esempio n. 2
0
def test_get_all(web_client: WebClient, package_ahriman: Package,
                 mocker: MockerFixture) -> None:
    """
    must return all packages status
    """
    response = [pytest.helpers.get_package_status_extended(package_ahriman)]
    response_obj = Response()
    response_obj._content = json.dumps(response).encode("utf8")
    response_obj.status_code = 200

    requests_mock = mocker.patch("requests.get", return_value=response_obj)

    result = web_client.get(None)
    requests_mock.assert_called_once()
    assert len(result) == len(response)
    assert (package_ahriman, BuildStatusEnum.Unknown) in [
        (package, status.status) for package, status in result
    ]