Skip to content

Commit

Permalink
add test on Price.location_osm_type validation
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Nov 27, 2023
1 parent b4ba32a commit 5add3e7
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,26 @@ def test_create_price_currency_validation(user):
# currency must have a specific format (ex: "EUR")
WRONG_PRICE_CURRENCIES = ["", "€", "euro"]
for wrong_price_currency in WRONG_PRICE_CURRENCIES:
PRICE_WITH_CATEGORY_TAG_ERROR = PRICE_1.model_copy(
PRICE_WITH_CURRENCY_ERROR = PRICE_1.model_copy(
update={"currency": wrong_price_currency}
)
response = client.post(
"/prices",
json=jsonable_encoder(PRICE_WITH_CATEGORY_TAG_ERROR),
json=jsonable_encoder(PRICE_WITH_CURRENCY_ERROR),
headers={"Authorization": f"Bearer {user.token}"},
)
assert response.status_code == 422


def test_create_price_location_osm_type_validation(user):
WRONG_PRICE_LOCATION_OSM_TYPES = ["", "node"]
for wrong_price_location_osm_type in WRONG_PRICE_LOCATION_OSM_TYPES:
PRICE_WITH_LOCATION_OSM_TYPE_ERROR = PRICE_1.model_copy(
update={"location_osm_type": wrong_price_location_osm_type}
)
response = client.post(
"/prices",
json=jsonable_encoder(PRICE_WITH_LOCATION_OSM_TYPE_ERROR),
headers={"Authorization": f"Bearer {user.token}"},
)
assert response.status_code == 422
Expand Down Expand Up @@ -207,12 +221,12 @@ def test_create_price_labels_tags_pattern_validation(user):
# product_code cannot be an empty string, nor contain letters
WRONG_PRICE_LABELS_TAGS = [[]]
for wrong_price_labels_tags in WRONG_PRICE_LABELS_TAGS:
PRICE_WITH_PRODUCT_CODE_ERROR = PRICE_1.model_copy(
PRICE_WITH_LABELS_TAGS_ERROR = PRICE_1.model_copy(
update={"labels_tags": wrong_price_labels_tags}
)
response = client.post(
"/prices",
json=jsonable_encoder(PRICE_WITH_PRODUCT_CODE_ERROR),
json=jsonable_encoder(PRICE_WITH_LABELS_TAGS_ERROR),
headers={"Authorization": f"Bearer {user.token}"},
)
assert response.status_code == 422
Expand Down

0 comments on commit 5add3e7

Please sign in to comment.