Revert "Fix other tests"

This reverts commit 54963e9f91.
This commit is contained in:
Evarin 2018-04-23 00:35:57 +02:00
parent 54963e9f91
commit 1142db73f7
2 changed files with 19 additions and 24 deletions

View file

@ -8,23 +8,23 @@ User = get_user_model()
class ClipperProviderTests(CASTestCase): class ClipperProviderTests(CASTestCase):
def setUp(self): def setUp(self):
pass self.u = User.objects.create_user('user', 'user@mail.net', 'user')
def test_auto_signup(self): def test_auto_signup(self):
self.client_cas_login( self.client_cas_login(
self.client, provider_id='clipper', username='clipperuid') self.client, provider_id='clipper', username='clipper_uid')
u = User.objects.get(username__contains='clipperuid') u = User.objects.get(username='clipper_uid')
self.assertEqual(u.email, 'clipperuid@clipper.ens.fr') self.assertEqual(u.email, 'clipper_uid@clipper.ens.fr')
class ClipperViewsTests(CASViewTestCase): class ClipperViewsTests(CASViewTestCase):
def test_login_view(self): def test_login_view(self):
r = self.client.get('/account/clipper/login/') r = self.client.get('/accounts/clipper/login/')
expected = ( expected = (
"https://cas.eleves.ens.fr/login?service=http%3A%2F%2Ftestserver" "https://cas.eleves.ens.fr/login?service=http%3A%2F%2Ftestserver"
"%2Faccount%2Fclipper%2Flogin%2Fcallback%2F" "%2Faccounts%2Fclipper%2Flogin%2Fcallback%2F"
) )
self.assertRedirects( self.assertRedirects(
r, expected, r, expected,
@ -33,20 +33,20 @@ class ClipperViewsTests(CASViewTestCase):
def test_callback_view(self): def test_callback_view(self):
# Required to initialize a SocialLogin. # Required to initialize a SocialLogin.
r = self.client.get('/account/clipper/login/') r = self.client.get('/accounts/clipper/login/')
# Tests. # Tests.
self.patch_cas_response(valid_ticket='__all__') self.patch_cas_response(valid_ticket='__all__')
r = self.client.get('/account/clipper/login/callback/', { r = self.client.get('/accounts/clipper/login/callback/', {
'ticket': '123456', 'ticket': '123456',
}) })
self.assertLoginSuccess(r, "/user/") self.assertLoginSuccess(r)
def test_logout_view(self): def test_logout_view(self):
r = self.client.get('/account/clipper/logout/') r = self.client.get('/accounts/clipper/logout/')
expected = ( expected = (
"https://cas.eleves.ens.fr/logout?service=http%3A%2F%2Ftestserver" "https://cas.eleves.ens.fr/logout?service=http%3A%2F%2Ftestserver"
"%2Fview%2F" "%2F"
) )
self.assertRedirects( self.assertRedirects(
r, expected, r, expected,

View file

@ -38,18 +38,13 @@ def prevent_logout_pwd_change(client, user):
session[HASH_SESSION_KEY] = user.get_session_auth_hash() session[HASH_SESSION_KEY] = user.get_session_auth_hash()
session.save() session.save()
"""
class ViewsTests(TestCase): class ViewsTests(TestCase):
""" ""
Checks (barely) that templates do not contain errors. Checks (barely) that templates do not contain errors.
""" ""
def setUp(self): def setUp(self):
try: self.u = User.objects.create_user('user', 'user@mail.net', 'user')
self.u = User.objects.get(username="user")
self.u.email = "user@mail.net"
self.u.save()
except User.DoesNotExist:
self.u = User.objects.create_user('user', 'user@mail.net', 'user')
Site.objects.filter(pk=1).update(domain='testserver') Site.objects.filter(pk=1).update(domain='testserver')
@ -60,14 +55,14 @@ class ViewsTests(TestCase):
def _get_confirm_email_link(self, email_msg): def _get_confirm_email_link(self, email_msg):
m = re.search( m = re.search(
r'http://testserver(/account/confirm-email/.*/)', r'http://testserver(/accounts/confirm-email/.*/)',
email_msg.body, email_msg.body,
) )
return m.group(1) return m.group(1)
def _get_reset_password_link(self, email_msg): def _get_reset_password_link(self, email_msg):
m = re.search( m = re.search(
r'http://testserver(/account/password/reset/key/.*/)', r'http://testserver(/accounts/password/reset/key/.*/)',
email_msg.body, email_msg.body,
) )
return m.group(1) return m.group(1)
@ -151,7 +146,7 @@ class ViewsTests(TestCase):
def test_account_reset_password_from_key_done(self): def test_account_reset_password_from_key_done(self):
r = self.client.get(reverse('account_reset_password_from_key_done')) r = self.client.get(reverse('account_reset_password_from_key_done'))
self.assertEqual(r.status_code, 200) self.assertEqual(r.status_code, 200)
"""
class LongTermClipperTests(CASTestCase): class LongTermClipperTests(CASTestCase):