From 9a43c9c4371f5ecad2eafd769166c8d4f3693d2c Mon Sep 17 00:00:00 2001 From: Phin Wolkwitz Date: Tue, 14 Apr 2026 15:15:37 +0200 Subject: [PATCH] Add location tests --- src/tests/api/test_items.py | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/tests/api/test_items.py b/src/tests/api/test_items.py index 9b6cbc78de..b2aef4737c 100644 --- a/src/tests/api/test_items.py +++ b/src/tests/api/test_items.py @@ -2062,6 +2062,59 @@ def test_program_times_create(token_client, organizer, event, item): assert resp.content.decode() == '{"non_field_errors":["The program end must not be before the program start."]}' +@pytest.mark.django_db +def test_program_times_create_location(token_client, organizer, event, item): + resp = token_client.post( + '/api/v1/organizers/{}/events/{}/items/{}/program_times/'.format(organizer.slug, event.slug, item.pk), + { + "start": "2017-12-27T00:00:00Z", + "end": "2017-12-28T00:00:00Z", + "location": { + "en": "Testlocation", + "de": "Testort" + } + }, + format='json' + ) + assert resp.status_code == 201 + with scopes_disabled(): + program_time = ItemProgramTime.objects.get(pk=resp.data['id']) + assert "Testlocation" == program_time.location.localize("en") + assert "Testort" == program_time.location.localize("de") + + +@pytest.mark.django_db +def test_program_times_create_without_location(token_client, organizer, event, item): + resp = token_client.post( + '/api/v1/organizers/{}/events/{}/items/{}/program_times/'.format(organizer.slug, event.slug, item.pk), + { + "start": "2017-12-27T00:00:00Z", + "end": "2017-12-28T00:00:00Z" + }, + format='json' + ) + assert resp.status_code == 201 + assert resp.data['location'] is None + with scopes_disabled(): + program_time = ItemProgramTime.objects.get(pk=resp.data['id']) + assert str(program_time.location) == "" + + resp = token_client.post( + '/api/v1/organizers/{}/events/{}/items/{}/program_times/'.format(organizer.slug, event.slug, item.pk), + { + "start": "2017-12-27T00:00:00Z", + "end": "2017-12-28T00:00:00Z", + "location": None + }, + format='json' + ) + assert resp.status_code == 201 + assert resp.data['location'] is None + with scopes_disabled(): + program_time = ItemProgramTime.objects.get(pk=resp.data['id']) + assert str(program_time.location) == "" + + @pytest.mark.django_db def test_program_times_update(token_client, organizer, event, item, program_time): resp = token_client.patch(