From 09d6bf68c363f148ca9a1210ab6060f5439bf2ac Mon Sep 17 00:00:00 2001 From: Jonas Dittrich <58814480+Kakadus@users.noreply.github.com> Date: Mon, 9 Oct 2023 23:10:20 +0200 Subject: [PATCH] cleanup advanced title logic --- evap/staff/tests/test_views.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/evap/staff/tests/test_views.py b/evap/staff/tests/test_views.py index 1bb7942667..287b8c6609 100644 --- a/evap/staff/tests/test_views.py +++ b/evap/staff/tests/test_views.py @@ -538,24 +538,13 @@ class TestUserExportView(WebTestStaffMode): @classmethod def setUpTestData(cls) -> None: cls.manager = make_manager() - baker.make(UserProfile, _quantity=5, _fill_optional=["first_name_given", "last_name", "email", "title"]) + # titles are not filled by baker because it has a default, see https://github.com/model-bakers/model_bakery/discussions/346 baker.make( UserProfile, _quantity=5, - _fill_optional=["first_name_given", "last_name", "email", "title"], - is_active=False, + _fill_optional=["first_name_given", "last_name", "email"], + title=cycle(("", "Some", "Custom", "Titles")), ) - # the titles are not filled by baker - titles = cycle(("", "Some", "Custom", "Titles")) - for user in UserProfile.objects.iterator(): - user.title = next(titles) - user.save() - - def assertUsersExported(self, response, user_objects): - reader = csv.reader(response.text.strip().split("\n")) - # skip header - next(reader) - self.assertSetEqual({tuple(row) for row in reader}, user_objects) def test_export_all(self): user_objects = { @@ -563,7 +552,11 @@ def test_export_all(self): for user in UserProfile.objects.iterator() } response = self.app.get(self.url, user=self.manager) - self.assertUsersExported(response, user_objects) + + reader = csv.reader(response.text.strip().split("\n")) + # skip header + next(reader) + self.assertSetEqual({tuple(row) for row in reader}, user_objects) class TestUserImportView(WebTestStaffMode):