Ejemplo n.º 1
0
def test_get_geography_no_msg_error(token):
    """
    A response with an unexpected http code and no "msg" should raise a FlowclientConnectionError.
    """
    connection_mock = Mock()
    connection_mock.get_url.return_value.status_code = 404
    connection_mock.get_url.return_value.json.return_value = {}
    with pytest.raises(
            FlowclientConnectionError,
            match=f"Could not get result. API returned with status code: 404.",
    ):
        get_geography(connection_mock, "DUMMY_AGGREGATION")
Ejemplo n.º 2
0
def test_get_geography_error(http_code, token):
    """
    Any unexpected http code should raise an exception.
    """
    connection_mock = Mock()
    connection_mock.get_url.return_value.status_code = http_code
    connection_mock.get_url.return_value.json.return_value = {"msg": "MESSAGE"}
    with pytest.raises(
            FlowclientConnectionError,
            match=
            f"Could not get result. API returned with status code: {http_code}. Reason: MESSAGE",
    ):
        get_geography(connection_mock, "DUMMY_AGGREGATION")
Ejemplo n.º 3
0
def test_get_geography(token):
    """
    Test that getting geography returns the returned dict
    """
    connection_mock = Mock()
    connection_mock.get_url.return_value.status_code = 200
    connection_mock.get_url.return_value.json.return_value = {"some": "json"}
    gj = get_geography(connection_mock, "DUMMY_AGGREGATION")
    assert {"some": "json"} == gj