Skip to content

Commit

Permalink
add fixture and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesfize committed May 23, 2024
1 parent 6fa7bee commit 4d6112b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/ref_geo/tests/test_ref_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def area_commune():
return db.session.execute(select(BibAreasTypes).filter_by(type_code="COM")).scalar_one()


@pytest.fixture(scope="function")
def area_departement():
return db.session.execute(select(BibAreasTypes).filter_by(type_code="DEP")).scalar_one()


@pytest.mark.usefixtures("client_class", "temporary_transaction")
class TestRefGeo:
expected_altitude = pytest.approx({"altitude_min": 984, "altitude_max": 2335}, rel=1e-2)
Expand Down Expand Up @@ -290,16 +295,19 @@ def test_get_areas_type_code(self, area_commune):
assert response.status_code == 200
assert all(area["id_type"] == area_commune.id_type for area in response.json)

def test_get_areas_type_codes(self):
def test_get_areas_type_codes(self, area_commune, area_departement):

type_codes = ["COM", "DEP"]
type_codes = [area_commune.type_code, area_departement.type_code]

response = self.client.get(
url_for("ref_geo.get_areas"), query_string={"type_code": ",".join(type_codes)}
)

assert response.status_code == 200
assert all(area["id_type"] in type_codes for area in response.json)
assert all(
area["id_type"] in [area_commune.id_type, area_departement.id_type]
for area in response.json
)

def test_get_areas_area_name(self):
response = self.client.get(url_for("ref_geo.get_areas"), query_string={"area_name": CITY})
Expand Down

0 comments on commit 4d6112b

Please sign in to comment.