class AutoLoginBackendTests(TestCase): def setUp(self): self.backend = AutoLoginBackend() def test_verify_with_email(self): """ If BROWSERID_AUTOLOGIN_EMAIL is set, use it to auth the user. """ with self.settings(BROWSERID_AUTOLOGIN_EMAIL='*****@*****.**', BROWSERID_AUTOLOGIN_ENABLED=True): self.assertEqual(self.backend.verify(), '*****@*****.**') def test_verify_without_email(self): """ If BROWSERID_AUTOLOGIN_EMAIL is not set, do not auth the user. """ with self.settings(BROWSERID_AUTOLOGIN_EMAIL='', BROWSERID_AUTOLOGIN_ENABLED=True): del settings.BROWSERID_AUTOLOGIN_EMAIL self.assertEqual(self.backend.verify(), None) def test_verify_disabled(self): """ If BROWSERID_AUTOLOGIN_ENABLED is False, do not auth the user in any case. """ with self.settings(BROWSERID_AUTOLOGIN_EMAIL='', BROWSERID_AUTOLOGIN_ENABLED=False): del settings.BROWSERID_AUTOLOGIN_EMAIL self.assertEqual(self.backend.verify(), None) with self.settings(BROWSERID_AUTOLOGIN_EMAIL='*****@*****.**', BROWSERID_AUTOLOGIN_ENABLED=False): self.assertEqual(self.backend.verify(), None)
def setUp(self): self.backend = AutoLoginBackend()