コード例 #1
0
    def test_most_recent_verification(self, create_photo_verification,
                                      create_sso_verification,
                                      first_verification,
                                      expected_verification):
        user = UserFactory.create()
        photo_verification = None
        sso_verification = None

        if not first_verification:
            if create_photo_verification:
                photo_verification = SoftwareSecurePhotoVerification.objects.create(
                    user=user)
            if create_sso_verification:
                sso_verification = SSOVerification.objects.create(user=user)
        elif first_verification == 'photo':
            photo_verification = SoftwareSecurePhotoVerification.objects.create(
                user=user)
            sso_verification = SSOVerification.objects.create(user=user)
        else:
            sso_verification = SSOVerification.objects.create(user=user)
            photo_verification = SoftwareSecurePhotoVerification.objects.create(
                user=user)

        most_recent = most_recent_verification(
            SoftwareSecurePhotoVerification.objects.all(),
            SSOVerification.objects.all(), 'created_at')

        if not expected_verification:
            self.assertEqual(most_recent, None)
        elif expected_verification == 'photo':
            self.assertEqual(most_recent, photo_verification)
        else:
            self.assertEqual(most_recent, sso_verification)
コード例 #2
0
ファイル: views.py プロジェクト: luisvasq/edx-platform
    def get_object(self):
        username = self.kwargs['username']
        photo_verifications = SoftwareSecurePhotoVerification.objects.filter(
            user__username=username).order_by('-updated_at')
        sso_verifications = SSOVerification.objects.filter(user__username=username).order_by('-updated_at')

        if photo_verifications or sso_verifications:
            verification = most_recent_verification(photo_verifications, sso_verifications, 'updated_at')
            self.check_object_permissions(self.request, verification)
            return verification

        raise Http404
コード例 #3
0
    def get_object(self):
        username = self.kwargs['username']
        photo_verifications = SoftwareSecurePhotoVerification.objects.filter(
            user__username=username).order_by('-updated_at')
        sso_verifications = SSOVerification.objects.filter(
            user__username=username).order_by('-updated_at')

        if photo_verifications or sso_verifications:
            verification = most_recent_verification(photo_verifications,
                                                    sso_verifications,
                                                    'updated_at')
            self.check_object_permissions(self.request, verification)
            return verification

        raise Http404
コード例 #4
0
ファイル: test_utils.py プロジェクト: rmulder/edx-platform
    def test_most_recent_verification(self, create_photo_verification,
                                      create_sso_verification,
                                      create_manual_verification,
                                      first_verification,
                                      expected_verification):

        user = UserFactory.create()
        photo_verification = None
        sso_verification = None
        manual_verification = None

        if not first_verification:
            if create_photo_verification:
                photo_verification = SoftwareSecurePhotoVerification.objects.create(
                    user=user)
            if create_sso_verification:
                sso_verification = SSOVerification.objects.create(user=user)
            if create_manual_verification:
                manual_verification = ManualVerification.objects.create(
                    user=user)
        elif first_verification == 'photo':
            photo_verification = SoftwareSecurePhotoVerification.objects.create(
                user=user)
            sso_verification = SSOVerification.objects.create(user=user)
        elif first_verification == 'sso':
            sso_verification = SSOVerification.objects.create(user=user)
            photo_verification = SoftwareSecurePhotoVerification.objects.create(
                user=user)
        else:
            manual_verification = ManualVerification.objects.create(user=user)
            photo_verification = SoftwareSecurePhotoVerification.objects.create(
                user=user)

        most_recent = most_recent_verification(
            SoftwareSecurePhotoVerification.objects.all(),
            SSOVerification.objects.all(), ManualVerification.objects.all(),
            'created_at')

        if not expected_verification:
            assert most_recent is None
        elif expected_verification == 'photo':
            assert most_recent == photo_verification
        elif expected_verification == 'sso':
            assert most_recent == sso_verification
        else:
            assert most_recent == manual_verification
コード例 #5
0
ファイル: test_utils.py プロジェクト: cmscom/edx-platform
    def test_most_recent_verification(
            self,
            create_photo_verification,
            create_sso_verification,
            create_manual_verification,
            first_verification,
            expected_verification):

        user = UserFactory.create()
        photo_verification = None
        sso_verification = None
        manual_verification = None

        if not first_verification:
            if create_photo_verification:
                photo_verification = SoftwareSecurePhotoVerification.objects.create(user=user)
            if create_sso_verification:
                sso_verification = SSOVerification.objects.create(user=user)
            if create_manual_verification:
                manual_verification = ManualVerification.objects.create(user=user)
        elif first_verification == 'photo':
            photo_verification = SoftwareSecurePhotoVerification.objects.create(user=user)
            sso_verification = SSOVerification.objects.create(user=user)
        elif first_verification == 'sso':
            sso_verification = SSOVerification.objects.create(user=user)
            photo_verification = SoftwareSecurePhotoVerification.objects.create(user=user)
        else:
            manual_verification = ManualVerification.objects.create(user=user)
            photo_verification = SoftwareSecurePhotoVerification.objects.create(user=user)

        most_recent = most_recent_verification(
            SoftwareSecurePhotoVerification.objects.all(),
            SSOVerification.objects.all(),
            ManualVerification.objects.all(),
            'created_at'
        )

        if not expected_verification:
            self.assertEqual(most_recent, None)
        elif expected_verification == 'photo':
            self.assertEqual(most_recent, photo_verification)
        elif expected_verification == 'sso':
            self.assertEqual(most_recent, sso_verification)
        else:
            self.assertEqual(most_recent, manual_verification)