Beispiel #1
0
    def test_LoginChoiceView_athlete_user(self):
        print('LoginChoiceView_athlete_user')
        create_athlete(self.data)
        self.client.login(**{'email': self.email, 'password': self.password})
        url = reverse('login choice')
        response = self.client.get(url)
        self.assertEqual(response.resolver_match.func.__name__,
                         'LoginChoiceView')

        self.assertRedirects(response, reverse('login') + '?next=' + url, 302)
Beispiel #2
0
 def test_anonymous_user_no_pass_prep(self):
     print('anonymous_user_no_pass_prep')
     athlete = create_athlete(self.data)
     url = reverse('change pass', kwargs={'slug': athlete.slug})
     with self.assertRaises(KeyError):
         self.client.post(url, {
             'initial': self.password,
             'confirm': self.password
         })
Beispiel #3
0
 def test_AthlleteDetailView_logged_user(self):
     print('AthleteDetailView_logged_user')
     athlete = create_athlete(self.data)
     url = reverse('athletes:athlete detail', kwargs={'slug': athlete.slug})
     self.client.login(**{'email': self.email, 'password': self.password})
     response = self.client.get(url)
     self.assertEqual(
         response.status_code,
         200  # OK
     )
Beispiel #4
0
 def test_RefereeDetailView_logged_non_referee_user(self):
     print('RefereeDetailView_logged_non_referee_user')
     athlete = create_athlete(self.data)
     self.client.login(**{'email': self.email, 'password': self.password})
     url = reverse('referees:referee detail', kwargs={'slug': athlete.slug})
     response = self.client.get(url)
     self.assertEqual(
         response.status_code,
         302  # Redirect
     )
     self.assertRedirects(response, reverse('login') + '?next=' + url)
Beispiel #5
0
 def test_invalid_code(self):
     print('invalid_code')
     athlete = create_athlete(self.data)
     set_key(athlete.user)
     url = reverse('pass change prep',
                   kwargs={
                       'slug': 'sharlon-regales',
                       'code': gen_key()
                   })
     with self.assertRaises(LookupError):
         self.client.get(url)
Beispiel #6
0
 def setup(self, key=None):
     if not key:
         self.athlete = create_athlete(self.data)
         key = set_key(self.athlete.user)
     url = reverse('pass change prep',
                   kwargs={
                       'slug': 'sharlon-regales',
                       'code': key
                   })
     self.response = self.client.get(url)
     self.assertEqual(self.response.resolver_match.func.__name__,
                      'ValidatePasswordChangeRequestView')
Beispiel #7
0
 def setup(self, login=False):
     if login:
         athlete = self.create_and_login(create_athlete)
     else:
         athlete = create_athlete(self.data)
         set_key(athlete.user, 'Forgot Password')
     url = reverse('change pass', kwargs={'slug': 'sharlon-regales'})
     self.response = self.client.post(url, {
         'initial': self.password,
         'confirm': self.password
     })
     self.assertEqual(self.response.resolver_match.func.__name__,
                      'ChangePasswordView')
Beispiel #8
0
 def test_anonymous_expired(self):
     print('anonymous_expired')
     athlete = create_athlete(self.data)
     set_key(athlete.user, 'Forgot Password')
     import datetime
     from pytz import timezone
     athlete.user.key_date = datetime.datetime.now(timezone('UTC')).replace(
         microsecond=0) - datetime.timedelta(days=1)
     athlete.user.save()
     url = reverse('change pass', kwargs={'slug': athlete.slug})
     with self.assertRaises(KeyError):
         self.client.post(url, {
             'initial': self.password,
             'confirm': self.password
         })
Beispiel #9
0
 def test_expired_code(self):
     print('expired_code')
     athlete = create_athlete(self.data)
     set_key(athlete.user)
     import datetime
     from pytz import timezone
     athlete.user.key_date = datetime.datetime.now(timezone('UTC')).replace(
         microsecond=0) - datetime.timedelta(days=1)
     athlete.user.save()
     url = reverse('pass change prep',
                   kwargs={
                       'slug': 'sharlon-regales',
                       'code': athlete.user.key
                   })
     with self.assertRaises(LookupError):
         self.client.get(url)
Beispiel #10
0
 def test_happy_path(self):
     print('happy_path')
     create_athlete(self.data)
     self.setup()
     self.assertRedirects(self.response, reverse('login'), 302)