Skip to content

Commit

Permalink
detox;
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbc committed Jul 4, 2024
1 parent 455c07c commit 88e7e34
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions solvis_graphql_api/composite_solution/cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import nzshm_model
import solvis
from solvis.inversion_solution.typing import InversionSolutionProtocol
# from solvis_store.query import get_fault_name_rupture_ids, get_location_radius_rupture_ids

from .filter_set_logic_options import SetOperationEnum, _solvis_join

# from solvis_store.query import get_fault_name_rupture_ids, get_location_radius_rupture_ids


if TYPE_CHECKING:
import shapely.geometry.polygon.Polygon
from nzshm_model.source_logic_tree.logic_tree import SourceLogicTree
Expand All @@ -27,6 +29,7 @@
# we want to use the solvis-store cache normally, override this in testing
RESOLVE_LOCATIONS_INTERNALLY = True # if DEPLOYMENT_STAGE == 'TEST' else True


@lru_cache
def get_location_polygon(radius_km: float, lon: float, lat: float) -> "shapely.geometry.polygon.Polygon":
return solvis.geometry.circle_polygon(radius_m=radius_km * 1000, lon=lon, lat=lat)
Expand Down Expand Up @@ -72,7 +75,7 @@ def get_rupture_ids_for_fault_names_stored(
rupture_set_id = ruptset_ids[0]
union = False if filter_set_options_dict["multiple_faults"] == SetOperationEnum.INTERSECTION else True

rupture_id_set: Set[int] = get_fault_name_rupture_ids(rupture_set_id, fault_names, union)
rupture_id_set: Set[int] = get_fault_name_rupture_ids(rupture_set_id, fault_names, union) # type: ignore # noqa
return rupture_id_set


Expand Down Expand Up @@ -142,7 +145,7 @@ def get_rupture_ids_for_location_radius_stored(
union = False if filter_set_options_dict["multiple_locations"] == SetOperationEnum.INTERSECTION else True
# print("filter_dataframe_by_radius_stored", radius_km)
# print("get_rupture_ids_for_location_radius_stored", radius_km)
rupture_ids: Iterator[int] = get_location_radius_rupture_ids(
rupture_ids: Iterator[int] = get_location_radius_rupture_ids( # type: ignore # noqa
rupture_set_id=rupture_set_id, locations=location_ids, radius=radius_km, union=union
)
return rupture_ids
Expand Down
3 changes: 2 additions & 1 deletion tests/test_composite_corupture_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@
def client():
return Client(schema_root)


@pytest.mark.skip('no')
@patch(
'solvis_graphql_api.composite_solution.cached.get_fault_name_rupture_ids',
lambda *args, **kwargs: [n for n in range(350, 390)]
lambda *args, **kwargs: [n for n in range(350, 390)],
)
@patch('solvis_graphql_api.composite_solution.cached.RESOLVE_LOCATIONS_INTERNALLY', True)
class TestFilterRptureSections:
Expand Down
1 change: 1 addition & 0 deletions tests/test_composite_rupture_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
def client():
return Client(schema_root)


@pytest.mark.skip('no')
# @patch(
# 'solvis_graphql_api.composite_solution.cached.get_location_radius_rupture_ids',
Expand Down
1 change: 1 addition & 0 deletions tests/test_rupture_sorting_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
MODEL_ID = "NSHM_v1.0.4"
FAULT_SYSTEM = "HIK"


@pytest.mark.skip('no')
@patch(
'solvis_graphql_api.composite_solution.cached.get_location_radius_rupture_ids',
Expand Down
2 changes: 2 additions & 0 deletions tests/test_ruptures_and_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from solvis_graphql_api.schema import schema_root


@patch('solvis_graphql_api.composite_solution.cached.RESOLVE_LOCATIONS_INTERNALLY', True)
class TestRupturePagination(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -108,6 +109,7 @@ def test_get_page_two(self):
assert len(rupts['edges']) == 3
assert from_global_id(rupts['edges'][0]['cursor']) == ("RuptureDetailConnectionCursor", "4")


@patch('solvis_graphql_api.composite_solution.cached.RESOLVE_LOCATIONS_INTERNALLY', True)
class TestRuptureDetailResolver(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 88e7e34

Please sign in to comment.