API: Validate input locales (Z#23182219) (#4833)

This commit is contained in:
Raphael Michel
2025-02-12 12:50:13 +01:00
committed by GitHub
parent 943193e8e0
commit 7afe2e66d7
5 changed files with 26 additions and 1 deletions

View File

@@ -622,6 +622,21 @@ def test_order_create_sales_channel_invalid(token_client, organizer, event, item
assert resp.data == {'sales_channel': ['Object with identifier=foo does not exist.']}
@pytest.mark.django_db
def test_order_create_locale_invalid(token_client, organizer, event, item, quota, question):
res = copy.deepcopy(ORDER_CREATE_PAYLOAD)
res['positions'][0]['item'] = item.pk
res['positions'][0]['answers'][0]['question'] = question.pk
res['locale'] = 'klingon'
resp = token_client.post(
'/api/v1/organizers/{}/events/{}/orders/'.format(
organizer.slug, event.slug
), format='json', data=res
)
assert resp.status_code == 400
assert resp.data == {'locale': ['"klingon" is not a valid choice.']}
@pytest.mark.django_db
def test_order_create_in_test_mode(token_client, organizer, event, item, quota, question):
res = copy.deepcopy(ORDER_CREATE_PAYLOAD)