Gérer la fin de scolarité #9

Merged
champeno merged 23 commits from Evarin/archicubes into master 2018-09-30 00:03:27 +02:00
Showing only changes of commit 9c3fc72ec0 - Show all commits

View file

@ -154,10 +154,10 @@ class LongTermClipperTests(CASTestCase):
def tearDown(self): def tearDown(self):
_mock_ldap.reset() _mock_ldap.reset()
def _setup_ldap(self, promo=12): def _setup_ldap(self, promo=12, username="test"):
import ldap import ldap
_mock_ldap.directory['dc=spi,dc=ens,dc=fr']={ _mock_ldap.directory['dc=spi,dc=ens,dc=fr']={
'uid': ['test'], 'uid': [username],
'cn': ['John Smith'], 'cn': ['John Smith'],
'mailRoutingAddress' : ['test@clipper.ens.fr'], 'mailRoutingAddress' : ['test@clipper.ens.fr'],
'homeDirectory': ["/users/%d/phy/test/" % promo], 'homeDirectory': ["/users/%d/phy/test/" % promo],
@ -247,3 +247,31 @@ class LongTermClipperTests(CASTestCase):
self.assertEqual(len(sa1), n_sa0+1) self.assertEqual(len(sa1), n_sa0+1)
self.assertEqual(n_u1, n_u0+1) self.assertEqual(n_u1, n_u0+1)
self.assertNotEqual(user1.id, user0.id) self.assertNotEqual(user1.id, user0.id)
def test_multiple_deprecation(self):
self._setup_ldap(12)
self._setup_ldap(15, "truc")
r = self.client_cas_login(self.client, provider_id="clipper",
username="test")
self.client.logout()
r = self.client_cas_login(self.client, provider_id="clipper",
username="truc")
self.client.logout()
sa0 = SocialAccount.objects.count()
deprecate_clippers()
self._setup_ldap(13)
r = self.client_cas_login(self.client, provider_id="clipper",
username="test")
self.client.logout()
sa1 = SocialAccount.objects.count()
deprecate_clippers()
sa2 = SocialAccount.objects.count()
# Older "test" inactive SocialAccount gets erased by new one
# while "truc" remains
self.assertEqual(sa0, sa2)
self.assertEqual(sa1, sa0+1)