Esempio n. 1
0
def test_get_self_failed_http_error(web_client: WebClient,
                                    mocker: MockerFixture) -> None:
    """
    must suppress any exception happened during service status getting
    """
    mocker.patch("requests.get", side_effect=requests.exceptions.HTTPError())
    assert web_client.get_self().status == BuildStatusEnum.Unknown
Esempio n. 2
0
def test_get_self(web_client: WebClient, mocker: MockerFixture) -> None:
    """
    must return service status
    """
    response_obj = Response()
    response_obj._content = json.dumps(BuildStatus().view()).encode("utf8")
    response_obj.status_code = 200

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

    result = web_client.get_self()
    requests_mock.assert_called_once()
    assert result.status == BuildStatusEnum.Unknown