コード例 #1
0
def test_check_review_app_custom_status_success(caplog):
    from review_app_status import _check_review_app_deployment_status

    responses.add(responses.GET, "https://foo-pr-bar.com", status=302)

    _check_review_app_deployment_status("https://foo-pr-bar.com", [200, 302], 5, 5)
    assert len(responses.calls) == 1
    assert len(caplog.records) == 1
    assert caplog.records[0].message == "Review app status: 302"
コード例 #2
0
def test_check_review_app_status_fail(caplog):
    from review_app_status import _check_review_app_deployment_status

    responses.add(responses.GET, "https://foo-pr-bar.com", status=503)

    with pytest.raises(TimeoutError) as excinfo:
        _check_review_app_deployment_status("https://foo-pr-bar.com", [200, 302], 5, 5)

    assert len(responses.calls) == 1
    assert (
        "Did not get any of the accepted status [200, 302] in the given time."
        in str(excinfo.value)
    )
    assert caplog.records[0].message == "Review app status: 503"
コード例 #3
0
def test_check_review_app_status_interval_greater_failure():

    from review_app_status import _check_review_app_deployment_status

    with pytest.raises(ValueError) as excinfo:
        url = _check_review_app_deployment_status(
            review_app_url="https://foo.bar",
            accepted_responses=[200],
            timeout=3,
            interval=4,
        )

    assert "Interval can't be greater than publish_timeout." in str(excinfo.value)