Make events tests deterministic

This commit is contained in:
Martin Pépin 2019-12-22 23:08:27 +01:00
parent d5e9d09044
commit e0fd3db638
2 changed files with 11 additions and 8 deletions

View file

@ -129,7 +129,13 @@ class CSVExportContentTest(MessagePatch, TestCase):
participants = self.client.get(self.url).content.decode("utf-8")
participants = list(csv.reader(participants.split("\n")))
toto_registration = participants[1]
# This is not super nice, but it makes the test deterministic.
if toto_registration[5] == "f & d":
toto_registration[5] = "d & f"
self.assertEqual(
["toto_foo", "toto@a.b", "toto", "foo", "a", "d & f", "hello"],
participants[1],
toto_registration,
)

View file

@ -36,14 +36,11 @@ def participants_csv(request, event_id):
row = [user.username, user.email, user.first_name, user.last_name]
# Options
options_choices = list(
" & ".join(
registration.options_choices.filter(option__id=id).values_list(
"choice", flat=True
)
)
all_choices = registration.options_choices.values_list("choice", flat=True)
options_choices = [
" & ".join(all_choices.filter(option__id=id))
for id in event.options.values_list("id", flat=True).order_by("id")
)
]
row += options_choices
# Extra info
extra_info = list(