Skip to content

Commit

Permalink
Fixed incorrect calls to renamed db function (#175)
Browse files Browse the repository at this point in the history
* Fixed incorrect calls to renamed db function

* Fixed linting issues

---------

Co-authored-by: Ricardo Garcia Silva <[email protected]>
  • Loading branch information
ricardogsilva and Ricardo Garcia Silva authored Jul 23, 2024
1 parent 16a258a commit d5c9f91
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
12 changes: 6 additions & 6 deletions arpav_ppcv/webapp/api_v2/routers/coverages.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ def get_coverage_configuration(
db_coverage_configuration = db.get_coverage_configuration(
db_session, coverage_configuration_id
)
allowed_coverage_identifiers = db.list_allowed_coverage_identifiers(
db_session, coverage_configuration_id=db_coverage_configuration.id
allowed_coverage_identifiers = db.generate_coverage_identifiers(
db_session, coverage_configuration=db_coverage_configuration
)
return coverage_schemas.CoverageConfigurationReadDetail.from_db_instance(
db_coverage_configuration, allowed_coverage_identifiers, request
Expand Down Expand Up @@ -407,8 +407,8 @@ def get_climate_barometer_time_series(
db_session, coverage_identifier
)
) is not None:
allowed_cov_ids = db.list_allowed_coverage_identifiers(
db_session, coverage_configuration_id=db_cov_conf.id
allowed_cov_ids = db.generate_coverage_identifiers(
db_session, coverage_configuration=db_cov_conf
)
if coverage_identifier in allowed_cov_ids:
coverage = CoverageInternal(
Expand Down Expand Up @@ -480,8 +480,8 @@ def get_time_series(
db_session, coverage_identifier
)
) is not None:
allowed_cov_ids = db.list_allowed_coverage_identifiers(
db_session, coverage_configuration_id=db_cov_conf.id
allowed_cov_ids = db.generate_coverage_identifiers(
db_session, coverage_configuration=db_cov_conf
)
if coverage_identifier in allowed_cov_ids:
coverage = CoverageInternal(
Expand Down
4 changes: 4 additions & 0 deletions arpav_ppcv/webapp/api_v2/schemas/coverages.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ def from_db_instance(
configuration_parameter_name=pv.configuration_parameter_value.configuration_parameter.name,
configuration_parameter_display_name_english=(
pv.configuration_parameter_value.configuration_parameter.display_name_english
or pv.configuration_parameter_value.configuration_parameter.name
),
configuration_parameter_display_name_italian=(
pv.configuration_parameter_value.configuration_parameter.display_name_italian
or pv.configuration_parameter_value.configuration_parameter.name
),
configuration_parameter_value=pv.configuration_parameter_value.name,
)
Expand Down Expand Up @@ -195,9 +197,11 @@ def from_db_instance(
configuration_parameter_name=pv.configuration_parameter_value.configuration_parameter.name,
configuration_parameter_display_name_english=(
pv.configuration_parameter_value.configuration_parameter.display_name_english
or pv.configuration_parameter_value.configuration_parameter.name
),
configuration_parameter_display_name_italian=(
pv.configuration_parameter_value.configuration_parameter.display_name_italian
or pv.configuration_parameter_value.configuration_parameter.name
),
configuration_parameter_value=pv.configuration_parameter_value.name,
)
Expand Down
26 changes: 26 additions & 0 deletions tests/test_webapp_v2_routers_coverages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import httpx

from arpav_ppcv.schemas import coverages


def test_coverage_configurations_list(
test_client_v2_app: httpx.Client,
sample_coverage_configurations: list[coverages.CoverageConfiguration],
):
list_response = test_client_v2_app.get(
test_client_v2_app.app.url_path_for("list_coverage_configurations"),
headers={"accept": "application/json"},
)
assert list_response.status_code == 200
assert len(list_response.json()["items"]) == 10


def test_coverage_identifiers_list(
test_client_v2_app: httpx.Client,
sample_coverage_configurations: list[coverages.CoverageConfiguration],
):
list_response = test_client_v2_app.get(
test_client_v2_app.app.url_path_for("list_coverage_identifiers"),
headers={"accept": "application/json"},
)
assert list_response.status_code == 200

0 comments on commit d5c9f91

Please sign in to comment.