Пример #1
0
    def test_user_details_force_sync_username_conflict(self):
        """
        The user details were attempted to be synced but the incoming username already exists for another account.

        An email should still be sent in this case.
        """
        # Create a user with an email that conflicts with the incoming value.
        UserFactory.create(username='******'.format(self.old_username))

        # Begin the pipeline.
        pipeline.user_details_force_sync(
            auth_entry=pipeline.AUTH_ENTRY_LOGIN,
            strategy=self.strategy,
            details=self.details,
            user=self.user,
        )

        # The username is not changed, but everything else is.
        user = User.objects.get(pk=self.user.pk)
        assert user.email == 'new+{}'.format(self.old_email)
        assert user.username == self.old_username
        assert user.profile.name == u'Grown Up {}'.format(self.old_fullname)
        assert user.profile.country == 'PK'

        # An email should still be sent because the email changed.
        assert len(mail.outbox) == 1
    def test_user_details_force_sync_username_conflict(self):
        """
        The user details were attempted to be synced but the incoming username already exists for another account.

        An email should still be sent in this case.
        """
        # Create a user with an email that conflicts with the incoming value.
        UserFactory.create(username='******'.format(self.old_username))

        # Begin the pipeline.
        pipeline.user_details_force_sync(
            auth_entry=pipeline.AUTH_ENTRY_LOGIN,
            strategy=self.strategy,
            details=self.details,
            user=self.user,
        )

        # The username is not changed, but everything else is.
        user = User.objects.get(pk=self.user.pk)
        assert user.email == 'new+{}'.format(self.old_email)
        assert user.username == self.old_username
        assert user.profile.name == 'Grown Up {}'.format(self.old_fullname)
        assert user.profile.country == 'PK'

        # An email should still be sent because the email changed.
        assert len(mail.outbox) == 1
    def test_user_details_force_sync_email_conflict(self):
        """
        The user details were attempted to be synced but the incoming email already exists for another account.
        """
        # Create a user with an email that conflicts with the incoming value.
        UserFactory.create(email='new+{}'.format(self.old_email))

        # Begin the pipeline.
        pipeline.user_details_force_sync(
            auth_entry=pipeline.AUTH_ENTRY_LOGIN,
            strategy=self.strategy,
            details=self.details,
            user=self.user,
        )

        # The email is not changed, but everything else is.
        user = User.objects.get(pk=self.user.pk)
        assert user.email == self.old_email
        assert user.profile.name == u'Grown Up {}'.format(self.old_fullname)
        assert user.profile.country == 'PK'

        # Now verify that username field is not updated
        assert user.username == self.old_username

        # No email should be sent for an email change.
        assert len(mail.outbox) == 0
Пример #4
0
    def test_user_details_force_sync_email_conflict(self):
        """
        The user details were attempted to be synced but the incoming email already exists for another account.
        """
        # Create a user with an email that conflicts with the incoming value.
        UserFactory.create(email='new+{}'.format(self.old_email))

        # Begin the pipeline.
        pipeline.user_details_force_sync(
            auth_entry=pipeline.AUTH_ENTRY_LOGIN,
            strategy=self.strategy,
            details=self.details,
            user=self.user,
        )

        # The email is not changed, but everything else is.
        user = User.objects.get(pk=self.user.pk)
        assert user.email == self.old_email
        assert user.profile.name == 'Grown Up {}'.format(self.old_fullname)
        assert user.profile.country == 'PK'

        # Now verify that username field is not updated
        assert user.username == self.old_username

        # No email should be sent for an email change.
        assert len(mail.outbox) == 0
Пример #5
0
    def test_user_details_force_sync(self):
        """
        The user details are synced properly and an email is sent when the email is changed.
        """
        # Begin the pipeline.
        pipeline.user_details_force_sync(
            auth_entry=pipeline.AUTH_ENTRY_LOGIN,
            strategy=self.strategy,
            details=self.details,
            user=self.user,
        )

        # User now has updated information in the DB.
        user = User.objects.get()
        assert user.email == 'new+{}'.format(self.old_email)
        assert user.username == 'new_{}'.format(self.old_username)
        assert user.profile.name == 'Grown Up {}'.format(self.old_fullname)
        assert user.profile.country == 'PK'

        assert len(mail.outbox) == 1