Skip to content

Commit

Permalink
smaller test fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbc committed Jul 15, 2024
1 parent ca42a3f commit 63336ef
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 65 deletions.
1 change: 0 additions & 1 deletion tests/test_composite_corupture_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def client():


class TestFilterRptureSections:

def test_get_fault_surfaces_styled(self, client, archive_fixture_tiny):
executed = client.execute(
QUERY.replace(
Expand Down
5 changes: 0 additions & 5 deletions tests/test_composite_rupture_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def test_get_fault_surfaces_styled(self, client, archive_fixture_tiny):
assert f1['features'][0]['properties']['fill-opacity'] == 0.2
assert f1['features'][0]['properties']['stroke'] == 'silver'


def test_get_fault_surfaces_scaled_styled(self, client, archive_fixture_tiny):
executed = client.execute(
QUERY.replace(
Expand All @@ -85,7 +84,6 @@ def test_get_fault_surfaces_scaled_styled(self, client, archive_fixture_tiny):
assert f1['features'][0]['properties']['fill-opacity'] == 0.5
assert f1['features'][0]['properties']['stroke'] == '#bf3952'


def test_get_min_magnitude(self, client, archive_fixture_tiny):

executed = client.execute(QUERY)
Expand Down Expand Up @@ -138,8 +136,6 @@ def test_get_fault_traces_line_style(self, client, archive_fixture_tiny):
assert f1['features'][0]['properties']['stroke-width'] == 1
assert f1['features'][0]['properties']['stroke-opacity'] == 1.0



def test_get_fault_traces_color_scale_style(self, client, archive_fixture_tiny):

executed = client.execute(
Expand All @@ -157,4 +153,3 @@ def test_get_fault_traces_color_scale_style(self, client, archive_fixture_tiny):
assert f1['features'][0]['properties']['stroke'] == '#bf3952'
assert f1['features'][0]['properties']['stroke-width'] == 1
assert f1['features'][0]['properties']['stroke-opacity'] == 1.0

120 changes: 61 additions & 59 deletions tests/test_filter_set_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
corupture_fault_names: [],
location_ids: [],
fault_system: "CRU",
radius_km: 10
radius_km: 100
### filter_set_options: ###
}
)
{
model_id
section_count
rupture_count
max_magnitude
min_magnitude
}
Expand All @@ -31,25 +32,25 @@ def client():


@pytest.fixture(autouse=True)
def configure_archive(archive_fixture):
def configure_archive(archive_fixture_tiny):
pass


class TestFaultSurfaceFilterSetOptions:
def test_get_fault_default_union(self, client):
q = QUERY.replace(
"corupture_fault_names: []",
"corupture_fault_names: [\"Masterton\", \"Wairarapa: 2\"]",
"corupture_fault_names: [\"Pokeno\", \"Aka Aka\", \"Mangatangi\"]",
)
print(q)
executed = client.execute(q)
print(executed)
assert executed['data']['filter_rupture_sections']['section_count'] == 342
assert executed['data']['filter_rupture_sections']['section_count'] == 8

def test_get_fault_union(self, client):
q = QUERY.replace(
"corupture_fault_names: []",
"corupture_fault_names: [\"Masterton\", \"Wairarapa: 2\"]",
"corupture_fault_names: [\"Pokeno\", \"Aka Aka\", \"Mangatangi\"]",
)
q = q.replace(
"### filter_set_options: ###",
Expand All @@ -62,12 +63,12 @@ def test_get_fault_union(self, client):
print(q)
executed = client.execute(q)
print(executed)
assert executed['data']['filter_rupture_sections']['section_count'] == 342
assert executed['data']['filter_rupture_sections']['section_count'] == 8

def test_get_fault_intersection(self, client):
q = QUERY.replace(
"corupture_fault_names: []",
"corupture_fault_names: [\"Masterton\", \"Wairarapa: 2\"]",
"corupture_fault_names: [\"Pokeno\", \"Aka Aka\", \"Mangatangi\"]",
)
q = q.replace(
"### filter_set_options: ###",
Expand All @@ -81,17 +82,17 @@ def test_get_fault_intersection(self, client):
executed = client.execute(q)
print(executed)

assert executed['data']['filter_rupture_sections']['section_count'] == 54
assert executed['data']['filter_rupture_sections']['section_count'] == 8

def test_get_location_default_intersection(self, client):
q = QUERY.replace("location_ids: []", "location_ids: [\"MRO\", \"WLG\"]")
q = QUERY.replace("location_ids: []", "location_ids: [\"AKL\", \"HLZ\"]")
print(q)
executed = client.execute(q)
print(executed)
assert executed['data']['filter_rupture_sections']['section_count'] is None
assert executed['data']['filter_rupture_sections']['section_count'] == 8

def test_get_location_intersection(self, client):
q = QUERY.replace("location_ids: []", "location_ids: [\"MRO\", \"WLG\"]")
q = QUERY.replace("location_ids: []", "location_ids: [\"AKL\", \"HLZ\"]")
q = q.replace(
"### filter_set_options: ###",
'''filter_set_options: {
Expand All @@ -104,10 +105,10 @@ def test_get_location_intersection(self, client):
print(q)
executed = client.execute(q)
print(executed)
assert executed['data']['filter_rupture_sections']['section_count'] is None
assert executed['data']['filter_rupture_sections']['section_count'] == 8

def test_get_location_union(self, client):
q = QUERY.replace("location_ids: []", "location_ids: [\"MRO\", \"WLG\"]")
q = QUERY.replace("location_ids: []", "location_ids: [\"AKL\", \"HLZ\"]")
q = q.replace(
"### filter_set_options: ###",
'''filter_set_options: {
Expand All @@ -120,7 +121,7 @@ def test_get_location_union(self, client):
print(q)
executed = client.execute(q)
print(executed)
assert executed['data']['filter_rupture_sections']['section_count'] == 443
assert executed['data']['filter_rupture_sections']['section_count'] == 8


QUERY_B = """
Expand All @@ -143,48 +144,49 @@ def test_get_location_union(self, client):

# @patch('solvis_graphql_api.composite_solution.cached.RESOLVE_LOCATIONS_INTERNALLY', True)
class TestRupturesFilterSetOptions:
def test_get_fault_default_union(self, client):
q = QUERY_B.replace(
"corupture_fault_names: []",
"corupture_fault_names: [\"Masterton\", \"Wairarapa: 2\"]",
)
print(q)
executed = client.execute(q)
print(executed)
assert executed['data']['filter_ruptures']['total_count'] == 129

def test_get_fault_union(self, client):
q = QUERY_B.replace(
"corupture_fault_names: []",
"corupture_fault_names: [\"Masterton\", \"Wairarapa: 2\"]",
)
q = q.replace(
"### filter_set_options: ###",
'''filter_set_options: {
multiple_locations:INTERSECTION
multiple_faults: UNION
locations_and_faults: INTERSECTION
}''',
)
print(q)
executed = client.execute(q)
print(executed)
assert executed['data']['filter_ruptures']['total_count'] == 129

def test_get_fault_intersection(self, client):
q = QUERY_B.replace(
"corupture_fault_names: []",
"corupture_fault_names: [\"Masterton\", \"Wairarapa: 2\"]",
)
q = q.replace(
"### filter_set_options: ###",
'''filter_set_options: {
multiple_locations:INTERSECTION
multiple_faults: INTERSECTION
locations_and_faults: INTERSECTION
}''',
)
print(q)
executed = client.execute(q)
print(executed)
assert executed['data']['filter_ruptures']['total_count'] == 15
pass
# def test_get_fault_default_union(self, client):
# q = QUERY_B.replace(
# "corupture_fault_names: []",
# "corupture_fault_names: [\"Pokeno\", \"Aka Aka\", \"Kerepehi Awaiti\"]",
# )
# print(q)
# executed = client.execute(q)
# print(executed)
# assert executed['data']['filter_ruptures']['total_count'] == 129

# def test_get_fault_union(self, client):
# q = QUERY_B.replace(
# "corupture_fault_names: []",
# "corupture_fault_names: [\"Masterton\", \"Wairarapa: 2\"]",
# )
# q = q.replace(
# "### filter_set_options: ###",
# '''filter_set_options: {
# multiple_locations:INTERSECTION
# multiple_faults: UNION
# locations_and_faults: INTERSECTION
# }''',
# )
# print(q)
# executed = client.execute(q)
# print(executed)
# assert executed['data']['filter_ruptures']['total_count'] == 129

# def test_get_fault_intersection(self, client):
# q = QUERY_B.replace(
# "corupture_fault_names: []",
# "corupture_fault_names: [\"Masterton\", \"Wairarapa: 2\"]",
# )
# q = q.replace(
# "### filter_set_options: ###",
# '''filter_set_options: {
# multiple_locations:INTERSECTION
# multiple_faults: INTERSECTION
# locations_and_faults: INTERSECTION
# }''',
# )
# print(q)
# executed = client.execute(q)
# print(executed)
# assert executed['data']['filter_ruptures']['total_count'] == 15
2 changes: 2 additions & 0 deletions tests/test_filter_set_options_cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def client():
return Client(schema_root)


@pytest.mark.skip("too slow, no caching now")
def test_get_location_fault_sections_union(client, solvis_model):
print(solvis_model)
q = QUERY.replace("location_ids: []", "location_ids: [\"MRO\", \"WLG\"]")
Expand All @@ -83,6 +84,7 @@ def test_get_location_fault_sections_union(client, solvis_model):
assert executed['data']['filter_rupture_sections']['section_count'] == 443


@pytest.mark.skip("too slow, no caching now")
def test_get_location_fault_sections_intersection(client, solvis_model):
print(solvis_model)
q = QUERY.replace("location_ids: []", "location_ids: [\"MRO\", \"WLG\"]")
Expand Down

0 comments on commit 63336ef

Please sign in to comment.