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) response = self.client.get(self.url)
content = self._load_from_csv_response(response, as_dict=True) self.assertCSVEqual(
toto_dict = dict(content[0]) response,
[
# This is not super nice, but it makes the test deterministic. {
toto_dict["def"] = set(x.strip() for x in toto_dict["def"].split("&")) "username": "toto_foo",
"prénom": "toto",
self.assertDictEqual( "nom de famille": "foo",
toto_dict, "email": "toto@a.b",
{ "abc": "a",
"username": "toto_foo", "def": "d & f",
"prénom": "toto", "remarks": "hello",
"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 # Options
all_choices = registration.options_choices.values_list("choice", flat=True) all_choices = registration.options_choices.values_list("choice", flat=True)
options_choices = [ 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") for id in event.options.values_list("id", flat=True).order_by("id")
] ]
row += options_choices row += options_choices