Ejemplo n.º 1
0
    def test_idempotent(self):
        """
        Tests that running a retirement multiple times does not throw an error
        """
        enrollment = self.create_enrollment_and_history()

        # Run twice to make sure no errors are raised
        _listen_for_lms_retire(sender=self.__class__, user=enrollment.user)
        fake_completed_retirement(enrollment.user)
        _listen_for_lms_retire(sender=self.__class__, user=enrollment.user)

        self.assert_enrollment_and_history_retired(enrollment)
Ejemplo n.º 2
0
    def test_idempotent(self):
        """
        Tests that running a retirement multiple times does not throw an error
        """
        enrollment = self.create_enrollment_and_history()

        # Run twice to make sure no errors are raised
        _listen_for_lms_retire(sender=self.__class__, user=enrollment.user)
        fake_completed_retirement(enrollment.user)
        _listen_for_lms_retire(sender=self.__class__, user=enrollment.user)

        self.assert_enrollment_and_history_retired(enrollment)
Ejemplo n.º 3
0
    def test_idempotent(self):
        verification = self._create_entry()

        # Run this twice to make sure there are no errors raised 2nd time through
        _listen_for_lms_retire(sender=self.__class__, user=verification.user)
        fake_completed_retirement(verification.user)
        _listen_for_lms_retire(sender=self.__class__, user=verification.user)

        ver_obj = SoftwareSecurePhotoVerification.objects.get(user=verification.user)

        # All values for this user should now be empty string
        for field in ('name', 'face_image_url', 'photo_id_image_url', 'photo_id_key'):
            self.assertEqual('', getattr(ver_obj, field))
Ejemplo n.º 4
0
    def test_idempotent(self):
        """
        Tests that re-running a retirement multiple times does not throw an error
        """
        answer = SurveyAnswerFactory(field_value="test value")

        # Run twice to make sure no errors are raised
        _listen_for_lms_retire(sender=self.__class__, user=answer.user)
        fake_completed_retirement(answer.user)
        _listen_for_lms_retire(sender=self.__class__, user=answer.user)

        # All values for this user should still be here and just be an empty string
        assert not SurveyAnswer.objects.filter(user=answer.user).exclude(field_value='').exists()
Ejemplo n.º 5
0
    def test_idempotent(self):
        """
        Tests that re-running a retirement multiple times does not throw an error
        """
        answer = SurveyAnswerFactory(field_value="test value")

        # Run twice to make sure no errors are raised
        _listen_for_lms_retire(sender=self.__class__, user=answer.user)
        fake_completed_retirement(answer.user)
        _listen_for_lms_retire(sender=self.__class__, user=answer.user)

        # All values for this user should still be here and just be an empty string
        self.assertFalse(SurveyAnswer.objects.filter(user=answer.user).exclude(field_value='').exists())
Ejemplo n.º 6
0
    def test_idempotent(self):
        verification = self._create_entry()

        # Run this twice to make sure there are no errors raised 2nd time through
        _listen_for_lms_retire(sender=self.__class__, user=verification.user)
        fake_completed_retirement(verification.user)
        _listen_for_lms_retire(sender=self.__class__, user=verification.user)

        ver_obj = SoftwareSecurePhotoVerification.objects.get(user=verification.user)

        # All values for this user should now be empty string
        for field in ('name', 'face_image_url', 'photo_id_image_url', 'photo_id_key'):
            self.assertEqual('', getattr(ver_obj, field))
def _setup_users():
    """
    Creates and returns test users in the different states of needing rehash:
    - Skipped: has not yet been retired
    - Faked: has been fake-retired, but the retired username does not require updating
    - Needing rehash: has been fake-retired and name changed so it triggers a hash update
    """
    # When we loop through creating users, take additional action on these
    user_indexes_to_be_fake_retired = (2, 4, 6, 8, 10)
    user_indexes_to_be_rehashed = (4, 6)

    users_skipped = []
    users_faked = []
    users_needing_rehash = []
    retirements = {}

    # Create some test users with retirements
    for i in range(1, 11):
        user = UserFactory()
        retirement = UserRetirementStatus.create_retirement(user)
        retirements[user.id] = retirement

        if i in user_indexes_to_be_fake_retired:
            fake_completed_retirement(user)

            if i in user_indexes_to_be_rehashed:
                # In order to need a rehash user.username must be the same as
                # retirement.retired_username and NOT the same as the hash
                # generated when the script is run. So we force that here.
                retirement.retired_username = retirement.retired_username.upper(
                )
                user.username = retirement.retired_username
                retirement.save()
                user.save()
                users_needing_rehash.append(user)
            else:
                users_faked.append(user)
        else:
            users_skipped.append(user)
    return users_skipped, users_faked, users_needing_rehash, retirements