コード例 #1
0
def with_apps(*apps):
    """
    Class decorator that makes sure the passed apps are present in
    INSTALLED_APPS.
    """
    apps_set = set(settings.INSTALLED_APPS)
    apps_set.update(apps)
    return override_settings(INSTALLED_APPS=list(apps_set))
コード例 #2
0
    def test_notify_recipients_function(self):
        with override_settings(
            REGISTRATION_NOTIFICATION_ADMINS=False,
            REGISTRATION_NOTIFICATION_MANAGERS=False,
            REGISTRATION_NOTIFICATION_RECIPIENTS=lambda: ("*****@*****.**", "*****@*****.**"),
        ):
            self.backend.register("bob", "*****@*****.**", request=self.mock_request)

            self.assertEqual(len(mail.outbox), 1)
            self.assertEqual(sorted(mail.outbox[0].to), sorted(["*****@*****.**", "*****@*****.**"]))
コード例 #3
0
def with_apps(*apps):
    """
    Class decorator that makes sure the passed apps are present in
    INSTALLED_APPS.
    """
    from django.conf import settings
    from registration.tests.compat import override_settings
    apps_set = set(settings.INSTALLED_APPS)
    apps_set.update(apps)
    return override_settings(INSTALLED_APPS=list(apps_set))
コード例 #4
0
    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([
                    '*****@*****.**',
                    '*****@*****.**',
                ]))
コード例 #5
0
    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([
                    '*****@*****.**',
                    '*****@*****.**',
                ]))
コード例 #6
0
    def test_notify_recipients_function(self):
        with override_settings(
            REGISTRATION_NOTIFICATION_ADMINS=False,
            REGISTRATION_NOTIFICATION_MANAGERS=False,
            REGISTRATION_NOTIFICATION_RECIPIENTS=lambda:(
                    '*****@*****.**',
                    '*****@*****.**',
                )):
            self.backend.register(
                    'bob', '*****@*****.**', request=self.mock_request
                )

            self.assertEqual(len(mail.outbox), 1)
            self.assertEqual(sorted(mail.outbox[0].to), sorted([
                    '*****@*****.**',
                    '*****@*****.**',
                ]))
コード例 #7
0
    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([
                    '*****@*****.**',
                    '*****@*****.**',
                ]))
コード例 #8
0
    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(
                    [
                        "*****@*****.**",
                        "*****@*****.**",
                        "*****@*****.**",
                        "*****@*****.**",
                        "*****@*****.**",
                        "*****@*****.**",
                    ]
                ),
            )
コード例 #9
0
    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())
コード例 #10
0
ファイル: tests.py プロジェクト: glisti/horsys
    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())
コード例 #11
0
    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([
                    '*****@*****.**',
                    '*****@*****.**',
                    '*****@*****.**',
                    '*****@*****.**',
                    '*****@*****.**',
                    '*****@*****.**',
                ]))
コード例 #12
0
    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([
                    '*****@*****.**',
                    '*****@*****.**',
                    '*****@*****.**',
                    '*****@*****.**',
                    '*****@*****.**',
                    '*****@*****.**',
                ]))