def test_notify_managers(self): with override_settings(REGISTRATION_NOTIFICATION_ADMINS=False): self.backend.register( 'bob', '*****@*****.**', request=self.mock_request ) self.assertEqual(len(mail.outbox), 1) self.assertEqual(sorted(mail.outbox[0].to), sorted([ '*****@*****.**', '*****@*****.**', ]))
def test_notify_admins(self): with override_settings(REGISTRATION_NOTIFICATION_MANAGERS=False): self.backend.register( 'bob', '*****@*****.**', request=self.mock_request ) self.assertEqual(len(mail.outbox), 1) self.assertEqual(sorted(mail.outbox[0].to), sorted([ '*****@*****.**', '*****@*****.**', ]))
def test_notify_admins(self): with override_settings(REGISTRATION_NOTIFICATION_MANAGERS=False): self.backend.register('bob', '*****@*****.**', request=self.mock_request) self.assertEqual(len(mail.outbox), 1) self.assertEqual(sorted(mail.outbox[0].to), sorted([ '*****@*****.**', '*****@*****.**', ]))
def test_notify_managers(self): with override_settings(REGISTRATION_NOTIFICATION_ADMINS=False): self.backend.register('bob', '*****@*****.**', request=self.mock_request) self.assertEqual(len(mail.outbox), 1) self.assertEqual( sorted(mail.outbox[0].to), sorted([ '*****@*****.**', '*****@*****.**', ]))
def test_no_auto_login_with_setting(self): """Auto login feature should be able to off with ``REGISTRATION_AUTO_LOGIN = False``""" self.mock_request.user = AnonymousUser() with override_settings(REGISTRATION_AUTO_LOGIN=False): new_user = self.backend.register("bob", "*****@*****.**", request=self.mock_request) self.backend.accept(new_user.registration_profile, request=self.mock_request) self.backend.activate( new_user.registration_profile.activation_key, password="******", request=self.mock_request ) self.failIf(self.mock_request.user.is_authenticated())
def test_notify_recipients_iterable(self): with override_settings( REGISTRATION_NOTIFICATION_ADMINS = False, REGISTRATION_NOTIFICATION_MANAGERS = False, REGISTRATION_NOTIFICATION_RECIPIENTS=( '*****@*****.**', '*****@*****.**', )): self.backend.register( 'bob', '*****@*****.**', request=self.mock_request ) self.assertEqual(len(mail.outbox), 1) self.assertEqual(sorted(mail.outbox[0].to), sorted([ '*****@*****.**', '*****@*****.**', ]))
def test_notify_recipients_iterable(self): with override_settings(REGISTRATION_NOTIFICATION_ADMINS=False, REGISTRATION_NOTIFICATION_MANAGERS=False, REGISTRATION_NOTIFICATION_RECIPIENTS=( '*****@*****.**', '*****@*****.**', )): self.backend.register('bob', '*****@*****.**', request=self.mock_request) self.assertEqual(len(mail.outbox), 1) self.assertEqual( sorted(mail.outbox[0].to), sorted([ '*****@*****.**', '*****@*****.**', ]))
def test_notify_duplicated(self): with override_settings(REGISTRATION_NOTIFICATION_ADMINS=True, REGISTRATION_NOTIFICATION_MANAGERS=True, REGISTRATION_NOTIFICATION_RECIPIENTS=( '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', ), ADMINS=( ('admin1', '*****@*****.**'), ('admin2', '*****@*****.**'), ('manager1', '*****@*****.**'), ('manager2', '*****@*****.**'), ('recipient1', '*****@*****.**'), ('recipient2', '*****@*****.**'), ), MANAGERS=( ('admin1', '*****@*****.**'), ('admin2', '*****@*****.**'), ('manager1', '*****@*****.**'), ('manager2', '*****@*****.**'), ('recipient1', '*****@*****.**'), ('recipient2', '*****@*****.**'), )): self.backend.register('bob', '*****@*****.**', request=self.mock_request) self.assertEqual(len(mail.outbox), 1) self.assertEqual( sorted(mail.outbox[0].to), sorted([ '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', ]))
def test_notify_duplicated(self): with override_settings( REGISTRATION_NOTIFICATION_ADMINS=True, REGISTRATION_NOTIFICATION_MANAGERS=True, REGISTRATION_NOTIFICATION_RECIPIENTS=( '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', ), ADMINS=( ('admin1', '*****@*****.**'), ('admin2', '*****@*****.**'), ('manager1', '*****@*****.**'), ('manager2', '*****@*****.**'), ('recipient1', '*****@*****.**'), ('recipient2', '*****@*****.**'), ), MANAGERS=( ('admin1', '*****@*****.**'), ('admin2', '*****@*****.**'), ('manager1', '*****@*****.**'), ('manager2', '*****@*****.**'), ('recipient1', '*****@*****.**'), ('recipient2', '*****@*****.**'), )): self.backend.register( 'bob', '*****@*****.**', request=self.mock_request ) self.assertEqual(len(mail.outbox), 1) self.assertEqual(sorted(mail.outbox[0].to), sorted([ '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', ]))
def test_no_auto_login_with_setting(self): """Auto login feature should be able to off with ``REGISTRATION_AUTO_LOGIN = False``""" self.mock_request.user = AnonymousUser() with override_settings(REGISTRATION_AUTO_LOGIN=False): new_user = self.backend.register( 'bob', '*****@*****.**', request=self.mock_request, ) self.backend.accept( new_user.registration_profile, request=self.mock_request, ) self.backend.activate( new_user.registration_profile.activation_key, password='******', request=self.mock_request, ) self.failIf(self.mock_request.user.is_authenticated())