Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
suzinyou committed Jul 29, 2024
1 parent 7cab97f commit ee6b666
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
6 changes: 5 additions & 1 deletion surveyscout/tasks/compute_cost/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from surveyscout.tasks.compute_cost.haversine import get_enum_target_haversine_matrix
from surveyscout.tasks.compute_cost.osrm import get_enum_target_osrm_matrix_async
from surveyscout.tasks.compute_cost.osrm import (
get_enum_target_osrm_matrix,
get_enum_target_osrm_matrix_async,
)
from surveyscout.tasks.compute_cost.google_distance_matrix import (
get_enum_target_google_distance_matrix,
)

__all__ = [
"get_enum_target_haversine_matrix",
"get_enum_target_osrm_matrix",
"get_enum_target_osrm_matrix_async",
"get_enum_target_google_distance_matrix",
]
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def patch_osrm_call(monkeysession: pytest.MonkeyPatch) -> None:
"surveyscout.tasks.compute_cost.osrm._get_enum_target_matrix_osrm",
mock_return_matrix,
)
monkeysession.setattr(
"surveyscout.tasks.compute_cost.osrm._get_enum_target_matrix_osrm_async",
mock_return_matrix,
)


success_element = {
Expand Down
16 changes: 14 additions & 2 deletions tests/test_tasks/test_compute_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from surveyscout.tasks.compute_cost import (
get_enum_target_haversine_matrix,
get_enum_target_osrm_matrix,
get_enum_target_osrm_matrix_async,
get_enum_target_google_distance_matrix,
)
Expand All @@ -23,14 +24,23 @@ def enum_target_haversine_matrix(


@pytest.fixture(scope="module")
def enum_target_osrm_matrix(
def enum_target_osrm_matrix_async(
enum_locs: LocationDataset, target_locs: LocationDataset
) -> NDArray:
return get_enum_target_osrm_matrix_async(
enum_locations=enum_locs, target_locations=target_locs
)


@pytest.fixture(scope="module")
def enum_target_osrm_matrix(
enum_locs: LocationDataset, target_locs: LocationDataset
) -> NDArray:
return get_enum_target_osrm_matrix(
enum_locations=enum_locs, target_locations=target_locs
)


@pytest.fixture(scope="module")
def enum_target_google_distance_matrix(
enum_locs: LocationDataset, target_locs: LocationDataset
Expand All @@ -40,13 +50,15 @@ def enum_target_google_distance_matrix(
)


@pytest.fixture(params=["osrm", "haversine", "google"])
@pytest.fixture(params=["osrm", "osrm_async", "haversine", "google"])
def cost_matrix(
request: pytest.FixtureRequest,
enum_locs: LocationDataset,
target_locs: LocationDataset,
) -> NDArray:
if request.param == "osrm":
return get_enum_target_osrm_matrix(enum_locs, target_locs)
if request.param == "osrm_async":
return get_enum_target_osrm_matrix_async(enum_locs, target_locs)
if request.param == "haversine":
return get_enum_target_haversine_matrix(enum_locs, target_locs)
Expand Down

0 comments on commit ee6b666

Please sign in to comment.