import requests


def _check_env_status(test_url, expected_status, last_hash):
    """
    Check the environment status by polling the report resource. Return
    True if the status matches the expected status, False otherwise.
    """
    rsp = requests.get(test_url)
    assert rsp.status_code == 200
    report_json = rsp.json()

    if report_json["env_status"] == expected_status:
        assert report_json["hash"] != last_hash
        return True
    else:
        return False