From 064c23902bed0e118652f72ba96a92ae8c4a7e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Sun, 30 Sep 2018 12:56:58 +0200 Subject: [PATCH] cof.tests -- Address flake8 concerns --- gestioncof/tests/test_views.py | 40 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/gestioncof/tests/test_views.py b/gestioncof/tests/test_views.py index 865bb56e..08da029f 100644 --- a/gestioncof/tests/test_views.py +++ b/gestioncof/tests/test_views.py @@ -165,9 +165,9 @@ class RegistrationViewTests(ViewTestCaseMixin, TestCase): o2 = e.options.create(name='Option 2', multi_choices=True) oc1 = o1.choices.create(value='O1 - Choice 1') - oc2 = o1.choices.create(value='O1 - Choice 2') + o1.choices.create(value='O1 - Choice 2') oc3 = o2.choices.create(value='O2 - Choice 1') - oc4 = o2.choices.create(value='O2 - Choice 2') + o2.choices.create(value='O2 - Choice 2') self.client.post(self.url, dict(self._minimal_data, **{ 'username': 'user', @@ -220,10 +220,10 @@ class RegistrationFormViewTests(ViewTestCaseMixin, TestCase): def test_empty(self): r = self.client.get(self.t_urls[0]) - user_form = r.context['user_form'] - profile_form = r.context['profile_form'] - events_form = r.context['event_formset'] - clubs_form = r.context['clubs_form'] + self.assertIn('user_form', r.context) + self.assertIn('profile_form', r.context) + self.assertIn('event_formset', r.context) + self.assertIn('clubs_form', r.context) def test_username(self): u = self.users['user'] @@ -233,11 +233,11 @@ class RegistrationFormViewTests(ViewTestCaseMixin, TestCase): r = self.client.get(self.t_urls[1]) + self.assertIn('user_form', r.context) + self.assertIn('profile_form', r.context) + self.assertIn('event_formset', r.context) + self.assertIn('clubs_form', r.context) user_form = r.context['user_form'] - profile_form = r.context['profile_form'] - events_form = r.context['event_formset'] - clubs_form = r.context['clubs_form'] - self.assertEqual(user_form['username'].initial, 'user') self.assertEqual(user_form['first_name'].initial, 'first') self.assertEqual(user_form['last_name'].initial, 'last') @@ -245,11 +245,12 @@ class RegistrationFormViewTests(ViewTestCaseMixin, TestCase): def test_clipper(self): r = self.client.get(self.t_urls[2]) + self.assertIn('user_form', r.context) + self.assertIn('profile_form', r.context) + self.assertIn('event_formset', r.context) + self.assertIn('clubs_form', r.context) user_form = r.context['user_form'] profile_form = r.context['profile_form'] - events_form = r.context['event_formset'] - clubs_form = r.context['clubs_form'] - self.assertEqual(user_form['first_name'].initial, 'First') self.assertEqual(user_form['last_name'].initial, 'Last1 Last2') self.assertEqual(user_form['email'].initial, 'uid@clipper.ens.fr') @@ -782,9 +783,10 @@ class CalendarViewTests(ViewTestCaseMixin, TestCase): fermeture=self.now, active=True, ) - l = Salle.objects.create() + location = Salle.objects.create() s = t.spectacle_set.create( - date=self.now, price=3.5, slots=20, location=l, listing=True) + date=self.now, price=3.5, slots=20, location=location, + listing=True) r = self.client.post(self.url, {'other_shows': [str(s.pk)]}) @@ -815,17 +817,17 @@ class CalendarICSViewTests(ViewTestCaseMixin, TestCase): fermeture=self.now, active=True, ) - l = Salle.objects.create(name='Location') + location = Salle.objects.create(name='Location') self.s1 = self.t.spectacle_set.create( - price=1, slots=10, location=l, listing=True, + price=1, slots=10, location=location, listing=True, title='Spectacle 1', date=self.now + timedelta(days=1), ) self.s2 = self.t.spectacle_set.create( - price=2, slots=20, location=l, listing=True, + price=2, slots=20, location=location, listing=True, title='Spectacle 2', date=self.now + timedelta(days=2), ) self.s3 = self.t.spectacle_set.create( - price=3, slots=30, location=l, listing=True, + price=3, slots=30, location=location, listing=True, title='Spectacle 3', date=self.now + timedelta(days=3), )