API: Fix sales channels when copying events (Z#23177154, Z#23169537)

This commit is contained in:
Raphael Michel
2024-12-20 14:08:39 +01:00
parent 3e15e2a887
commit 13c40f9bb7
3 changed files with 52 additions and 4 deletions

View File

@@ -497,6 +497,51 @@ def test_event_create_with_clone(token_client, organizer, event, meta_prop, urls
assert cloned_event.plugins == ""
@pytest.mark.django_db
@pytest.mark.parametrize("urlstyle", [
'/api/v1/organizers/{}/events/{}/clone/',
'/api/v1/organizers/{}/events/?clone_from={}',
])
def test_event_create_with_clone_migrate_sales_channels(token_client, organizer, event, meta_prop, urlstyle):
with scopes_disabled():
all_channels = list(organizer.sales_channels.values_list("identifier", flat=True))
resp = token_client.post(
urlstyle.format(organizer.slug, event.slug),
{
"name": {
"de": "Demo Konference 2020 Test",
"en": "Demo Conference 2020 Test"
},
"live": False,
"testmode": True,
"currency": "EUR",
"date_from": "2018-12-27T10:00:00Z",
"date_to": "2018-12-28T10:00:00Z",
"date_admission": "2018-12-27T08:00:00Z",
"is_public": False,
"presale_start": None,
"presale_end": None,
"location": None,
"slug": "2030",
"sales_channels": all_channels,
"meta_data": {
"type": "Workshop"
},
"plugins": [
"pretix.plugins.ticketoutputpdf"
],
"timezone": "Europe/Vienna"
},
format='json'
)
assert resp.status_code == 201
with scopes_disabled():
cloned_event = Event.objects.get(organizer=organizer.pk, slug='2030')
assert cloned_event.all_sales_channels
assert not cloned_event.limit_sales_channels.exists()
@pytest.mark.django_db
def test_event_create_with_clone_unknown_source(user, user_client, organizer, event):
with scopes_disabled():