Skip to content

Commit

Permalink
Fix tests, fix another couple of direct returns of APIQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
greenape committed Apr 24, 2020
1 parent f8d27b8 commit 2ec5332
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
6 changes: 2 additions & 4 deletions flowclient/flowclient/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@ def meaningful_locations_between_label_od_matrix(
.. [1] S. Isaacman et al., "Identifying Important Places in People's Lives from Cellular Network Data", International Conference on Pervasive Computing (2011), pp 133-151.
.. [2] Zagatti, Guilherme Augusto, et al. "A trip to work: Estimation of origin and destination of commuting patterns in the main metropolitan regions of Haiti using CDR." Development Engineering 3 (2018): 133-165.
"""
return APIQuery(
connection=connection,
return connection.make_api_query(
parameters=meaningful_locations_between_label_od_matrix_spec(**kwargs),
)

Expand Down Expand Up @@ -631,8 +630,7 @@ def meaningful_locations_between_dates_od_matrix(
.. [1] S. Isaacman et al., "Identifying Important Places in People's Lives from Cellular Network Data", International Conference on Pervasive Computing (2011), pp 133-151.
.. [2] Zagatti, Guilherme Augusto, et al. "A trip to work: Estimation of origin and destination of commuting patterns in the main metropolitan regions of Haiti using CDR." Development Engineering 3 (2018): 133-165.
"""
return APIQuery(
connection=connection,
return connection.make_api_query(
parameters=meaningful_locations_between_dates_od_matrix_spec(**kwargs),
)

Expand Down
26 changes: 16 additions & 10 deletions integration_tests/tests/query_tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,13 @@ async def test_fail_query_incorrect_parameters(

@pytest.mark.asyncio
@pytest.mark.parametrize(
"connection", [flowclient.Connection, flowclient.ASyncConnection]
"connection, module",
[
(flowclient.Connection, flowclient),
(flowclient.ASyncConnection, flowclient.async_client),
],
)
async def test_get_geography(connection, access_token_builder, flowapi_url):
async def test_get_geography(connection, module, access_token_builder, flowapi_url):
"""
Test that queries can be run, and return a GeoJSON dict.
"""
Expand All @@ -666,13 +670,11 @@ async def test_get_geography(connection, access_token_builder, flowapi_url):
token=access_token_builder(["get_result&geography.aggregation_unit.admin3"]),
)
try:
result_geojson = await flowclient.get_geography(
result_geojson = await module.get_geography(
connection=con, aggregation_unit="admin3"
)
except TypeError:
result_geojson = flowclient.get_geography(
connection=con, aggregation_unit="admin3"
)
result_geojson = module.get_geography(connection=con, aggregation_unit="admin3")
assert "FeatureCollection" == result_geojson["type"]
assert 0 < len(result_geojson["features"])
feature0 = result_geojson["features"][0]
Expand All @@ -685,7 +687,11 @@ async def test_get_geography(connection, access_token_builder, flowapi_url):

@pytest.mark.asyncio
@pytest.mark.parametrize(
"connection", [flowclient.Connection, flowclient.ASyncConnection]
"connection, module",
[
(flowclient.Connection, flowclient),
(flowclient.ASyncConnection, flowclient.async_client),
],
)
@pytest.mark.parametrize(
"event_types, expected_result",
Expand Down Expand Up @@ -748,7 +754,7 @@ async def test_get_geography(connection, access_token_builder, flowapi_url):
],
)
async def test_get_available_dates(
connection, event_types, expected_result, access_token_builder, flowapi_url
connection, module, event_types, expected_result, access_token_builder, flowapi_url
):
"""
Test that queries can be run, and return the expected JSON result.
Expand All @@ -757,9 +763,9 @@ async def test_get_available_dates(
url=flowapi_url, token=access_token_builder(["get_result&available_dates"]),
)
try:
result = await flowclient.get_available_dates(
result = await module.get_available_dates(
connection=con, event_types=event_types
)
except TypeError:
result = flowclient.get_available_dates(connection=con, event_types=event_types)
result = module.get_available_dates(connection=con, event_types=event_types)
assert expected_result == result

0 comments on commit 2ec5332

Please sign in to comment.