Skip to content

Commit 5c77c2d

Browse files
committed
test: use sorting in person study groups test
Use sorted, deterministic data in person study groups testing and snapshot. Future test runs will compare against this sorted snapshot. Refs: PT-1989
1 parent 76401fa commit 5c77c2d

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

organisations/tests/__snapshots__/test_api.ambr

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,30 +421,27 @@
421421
'edges': list([
422422
dict({
423423
'node': dict({
424-
'groupName': 'Hand human value base pattern democratic focus. Kind various laugh smile behavior.',
424+
'groupName': 'Group 00',
425425
}),
426426
}),
427427
dict({
428428
'node': dict({
429-
'groupName': 'Close term where up notice environment father stay. Hold project month similar support line.',
429+
'groupName': 'Group 01',
430430
}),
431431
}),
432432
dict({
433433
'node': dict({
434-
'groupName': 'Eat design give per kind history ahead. Herself consider fight us claim. Age feeling speech eye.',
434+
'groupName': 'Group 02',
435435
}),
436436
}),
437437
dict({
438438
'node': dict({
439-
'groupName': '''
440-
Apply somebody especially far. Color price environmental.
441-
Market him beyond.
442-
''',
439+
'groupName': 'Group 03',
443440
}),
444441
}),
445442
dict({
446443
'node': dict({
447-
'groupName': 'Civil find learn follow. Tend practice other poor.',
444+
'groupName': 'Group 04',
448445
}),
449446
}),
450447
]),

organisations/tests/test_api.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,14 +869,22 @@ def test_person_study_groups(
869869
person = event_staff_api_client.user.person
870870
person.organisations.add(organisation)
871871
p_event = PalvelutarjotinEventFactory(organisation=organisation)
872-
EnrolmentFactory.create_batch(
873-
5, study_group__person=person, person=person, occurrence__p_event=p_event
874-
)
872+
for i in range(5):
873+
EnrolmentFactory.create(
874+
study_group__person=person,
875+
study_group__group_name=f"Group {i:02d}",
876+
person=person,
877+
occurrence__p_event=p_event,
878+
)
875879
assert person.studygroup_set.count() == 5
876880
executed = event_staff_api_client.execute(
877881
PERSON_STUDY_GROUPS_QUERY,
878882
variables={"id": to_global_id("PersonNode", person.id)},
879883
)
884+
edges = executed["data"]["person"]["studygroupSet"]["edges"]
885+
executed["data"]["person"]["studygroupSet"]["edges"] = sorted(
886+
edges, key=lambda x: x["node"]["groupName"]
887+
)
880888
assert len(executed["data"]["person"]["studygroupSet"]["edges"]) == 5
881889
snapshot.assert_match(executed)
882890

0 commit comments

Comments
 (0)