toulouse-maelis: sort activities on global catalog (#87953)
gitea/passerelle/pipeline/head This commit looks good Details

This commit is contained in:
Nicolas Roche 2024-03-08 15:57:16 +01:00
parent 0f75026c9a
commit 5d26332646
2 changed files with 28 additions and 16 deletions

View File

@ -3061,6 +3061,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
)
update_criterias_order_field(all_criterias)
data.sort(key=lambda x: (x['unit']['dateStart'], x['unit']['dateEnd'], x['text']))
return {
'data': data,
'meta': {

View File

@ -6745,8 +6745,14 @@ def test_read_activity_list(con, app, freezer):
resp = app.get(url)
assert resp.json['err'] == 0
assert len(resp.json['data']) == 9
activity_text = [x['activity']['text'] for x in resp.json['data']]
assert activity_text == sorted(activity_text)
# activities are sorted by dates
activities = [
(x['unit']['dateStart'], x['unit']['dateEnd'], x['activity']['text']) for x in resp.json['data']
]
assert activities == sorted(activities)
# services label is added to activities if a service id is provided
assert [
(
x['id'],
@ -6755,28 +6761,33 @@ def test_read_activity_list(con, app, freezer):
)
for x in resp.json['data']
] == [
('A10056517594-A10056517595-A10056517597', 'plop', None),
('A10056517599-A10056517596-A10056517597', 'plop', None),
('A10051141965-A10051141990-A10053179227', 'A10049329051', 'Sorties'),
('A10051141965-A10051141968-A10053179226', 'A10049329051', 'Sorties'),
('A10051141965-A10051141966-A10053179226', 'A10049329051', 'Sorties'),
('A10056514645-A10056514650-A10053179757', None, None),
('A10056514645-A10056514648-A10053179876', None, None),
('A10056514645-A10056514649-A10053179757', None, None),
('A10051141965-A10051141966-A10053179226', 'A10049329051', 'Sorties'),
('A10051141965-A10051141968-A10053179226', 'A10049329051', 'Sorties'),
('A10051141965-A10051141970-A10053179226', 'A10049329051', 'Sorties'),
('A10051141965-A10051141990-A10053179227', 'A10049329051', 'Sorties'),
('A10056517594-A10056517595-A10056517597', 'plop', None),
('A10056517599-A10056517596-A10056517597', 'plop', None),
]
# item text differs on so called maelis "standard" and "non-standard" activities
resp = app.get(url)
standard_item = resp.json['data'][0] # activity having only one (standard) unit
non_standard_item = resp.json['data'][2] # activity having many units
assert standard_item['text'] == 'Promenade forêt enchantée, TERRITOIRE OUEST'
assert (
non_standard_item['text']
== 'TEST ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES (MERCREDI - 13h45/17h - 8/15Ans), ARGOULETS'
)
# * standard : activity having only one (standard) unit
# * non-standard : activity having many units -> unit is precised within parenthesis
assert [x['text'] for x in resp.json['data']] == [
'Vitrail Fusing 1/2 Je Adultes 2022/2023 - Mardi 14h-17h (Inscription 1er semestre), Un autre centre culturel',
'Vitrail Fusing 1/2 Je Adultes 2022/2023 - Mardi 14h-17h (Inscription annuelle), Centre Culturel ALBAN MINVILLE',
'Vitrail Fusing 1/2 Je Adultes 2022/2023 - Mardi 14h-17h (Vitrail Fusing 1/2 Je Adultes 2022/2023 - Mardi 14h-17h), Centre Culturel ALBAN MINVILLE',
'TEST ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES (MERCREDI - 13h45/17h - 8/15Ans), ARGOULETS',
'TEST ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES (MERCREDI - 14h/16h30 - 10/15Ans), LA RAMEE',
'TEST ECOLE DES SPORTS 22/23 SEMESTRE 2 - MULTIACTIVITES (MERCREDI - 15h30/17h - 8/15Ans), ARGOULETS',
'Vitrail Fusing 1/2 Je Adultes 2022/2023 - Mardi 14h-17h (Inscription 2ème semestre), Centre Culturel ALBAN MINVILLE',
'Promenade forêt enchantée, TERRITOIRE OUEST',
'Promenade forêt enchantée, TERRITOIRE OUEST',
]
item = resp.json['data'][5]
item = resp.json['data'][2]
assert item['activity']['service'] == {
'id': 'A10049329051',
'lib1': 'Sorties',