Make events tests deterministic

This commit is contained in:
Martin Pépin 2020-05-14 21:23:25 +02:00
parent 6fff995ccd
commit 707b7b76db
2 changed files with 14 additions and 18 deletions

View file

@ -140,21 +140,17 @@ class CSVExportContentTest(MessagePatch, CSVResponseMixin, TestCase):
)
response = self.client.get(self.url)
content = self._load_from_csv_response(response, as_dict=True)
toto_dict = dict(content[0])
# This is not super nice, but it makes the test deterministic.
toto_dict["def"] = set(x.strip() for x in toto_dict["def"].split("&"))
self.assertDictEqual(
toto_dict,
{
"username": "toto_foo",
"prénom": "toto",
"nom de famille": "foo",
"email": "toto@a.b",
"abc": "a",
"def": {"d", "f"},
"remarks": "hello",
},
self.assertCSVEqual(
response,
[
{
"username": "toto_foo",
"prénom": "toto",
"nom de famille": "foo",
"email": "toto@a.b",
"abc": "a",
"def": "d & f",
"remarks": "hello",
}
],
)

View file

@ -38,7 +38,7 @@ def participants_csv(request, event_id):
# Options
all_choices = registration.options_choices.values_list("choice", flat=True)
options_choices = [
" & ".join(all_choices.filter(option__id=id))
" & ".join(all_choices.filter(option__id=id).order_by("id"))
for id in event.options.values_list("id", flat=True).order_by("id")
]
row += options_choices