diff --git a/allauth_ens/tests.py b/allauth_ens/tests.py index ae5ba68..5272614 100644 --- a/allauth_ens/tests.py +++ b/allauth_ens/tests.py @@ -162,7 +162,11 @@ class LongTermClipperTests(CASTestCase): 'mailRoutingAddress' : ['test@clipper.ens.fr'], 'homeDirectory': ["/users/%d/phy/test/" % promo], } - + + def _count_ldap_queries(self): + queries = _mock_ldap.ldap_methods_called() + count = len([l for l in queries if l != 'set_option']) + return count def test_new_connexion(self): self._setup_ldap() @@ -174,6 +178,7 @@ class LongTermClipperTests(CASTestCase): self.assertEqual(u.first_name, "John") self.assertEqual(u.last_name, "Smith") self.assertEqual(u.email, "test@clipper.ens.fr") + self.assertEqual(self._count_ldap_queries(), 1) sa = list(SocialAccount.objects.all())[-1] self.assertEqual(sa.user.id, u.id) @@ -197,6 +202,7 @@ class LongTermClipperTests(CASTestCase): self.client_cas_login(self.client, provider_id="clipper", username="test") self.assertEqual(User.objects.count(), nu) + self.assertEqual(self._count_ldap_queries(), 1) def test_deprecation(self): self._setup_ldap() @@ -225,6 +231,7 @@ class LongTermClipperTests(CASTestCase): self.assertEqual(len(sa1), n_sa0) self.assertEqual(n_u1, n_u0) self.assertEqual(user1.id, user0.id) + self.assertEqual(self._count_ldap_queries(), 2) def test_override_inactive_account(self): self._setup_ldap(12)