Skip to content

Commit 50d0c36

Browse files
committed
test: use sorting in person queued enrolments test
Use sorted, deterministic data in person queued enrolments testing and snapshot. Future test runs will compare against this sorted snapshot. Refs: PT-1996
1 parent 0bc32a9 commit 50d0c36

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

organisations/tests/__snapshots__/test_api.ambr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,35 +373,35 @@
373373
dict({
374374
'node': dict({
375375
'studyGroup': dict({
376-
'groupName': 'Let join might player example environment. Then offer organization model.',
376+
'groupName': 'Group 00',
377377
}),
378378
}),
379379
}),
380380
dict({
381381
'node': dict({
382382
'studyGroup': dict({
383-
'groupName': 'By rate activity business let art. Admit think edge once election seat.',
383+
'groupName': 'Group 01',
384384
}),
385385
}),
386386
}),
387387
dict({
388388
'node': dict({
389389
'studyGroup': dict({
390-
'groupName': 'Play make war chance discover throw. Crime imagine wall two economy. Far power animal society Mrs.',
390+
'groupName': 'Group 02',
391391
}),
392392
}),
393393
}),
394394
dict({
395395
'node': dict({
396396
'studyGroup': dict({
397-
'groupName': 'Reach ask I cut ok. Perhaps teacher involve all my improve our Congress.',
397+
'groupName': 'Group 03',
398398
}),
399399
}),
400400
}),
401401
dict({
402402
'node': dict({
403403
'studyGroup': dict({
404-
'groupName': 'Second yet pay. First teach democratic.',
404+
'groupName': 'Group 04',
405405
}),
406406
}),
407407
}),

organisations/tests/test_api.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,23 @@ def test_person_queued_enrolments(
740740
person = event_staff_api_client.user.person
741741
person.organisations.add(organisation)
742742
p_event = PalvelutarjotinEventFactory(organisation=organisation)
743-
EventQueueEnrolmentFactory.create_batch(5, person=person, p_event=p_event)
743+
for i in range(5):
744+
EventQueueEnrolmentFactory.create(
745+
person=person,
746+
study_group__person=person,
747+
study_group__group_name=f"Group {i:02d}",
748+
p_event=p_event,
749+
)
744750
assert person.eventqueueenrolment_set.all().count() == 5
745751
event_staff_api_client.user.person.organisations.add(organisation)
746752
executed = event_staff_api_client.execute(
747753
PERSON_QUEUED_ENROLMENTS_QUERY,
748754
variables={"id": to_global_id("PersonNode", person.id)},
749755
)
756+
edges = executed["data"]["person"]["eventqueueenrolmentSet"]["edges"]
757+
executed["data"]["person"]["eventqueueenrolmentSet"]["edges"] = sorted(
758+
edges, key=lambda x: x["node"]["studyGroup"]["groupName"]
759+
)
750760
assert len(executed["data"]["person"]["eventqueueenrolmentSet"]["edges"]) == 5
751761
snapshot.assert_match(executed)
752762

0 commit comments

Comments
 (0)