More relevant tests for register_cas_account
This commit is contained in:
parent
a71688bbd5
commit
73cf73157c
1 changed files with 9 additions and 6 deletions
|
@ -25,13 +25,18 @@ class TestRegisterCasAccount(TestCase):
|
|||
self.assertEqual(user.cas_account.entrance_year, 2019)
|
||||
|
||||
def test_cant_register_twice(self):
|
||||
user = User.objects.create_user(username="whatever")
|
||||
CASAccount.objects.create(user=user, cas_login="johndoe", entrance_year=2019)
|
||||
john = User.objects.create_user(username="whatever")
|
||||
CASAccount.objects.create(user=john, cas_login="johndoe", entrance_year=2019)
|
||||
|
||||
janis = User.objects.create_user(username="janisjoplin")
|
||||
|
||||
# John cannot have two CAS accounts
|
||||
with self.assertRaises(ValueError):
|
||||
register_cas_account(user, cas_login="johndoe")
|
||||
register_cas_account(john, cas_login="joplin")
|
||||
|
||||
# Janis cannot steal John's account
|
||||
with self.assertRaises(ValueError):
|
||||
register_cas_account(user, cas_login="janisjoplin")
|
||||
register_cas_account(janis, cas_login="johndoe")
|
||||
|
||||
self.assertEqual(CASAccount.objects.count(), 1)
|
||||
|
||||
|
@ -41,7 +46,5 @@ class TestRegisterCasAccount(TestCase):
|
|||
|
||||
with self.assertRaises(ValueError):
|
||||
register_cas_account(user, cas_login="toto")
|
||||
with self.assertRaises(ValueError):
|
||||
register_cas_account(user, cas_login="ninasimone")
|
||||
|
||||
self.assertFalse(CASAccount.objects.exists())
|
||||
|
|
Loading…
Reference in a new issue