def test_get_user_attempts(self): """ Test adding verification status. """ VerificationStatus.add_verification_status( checkpoint=self.first_checkpoint, user=self.user, status='submitted') actual_attempts = VerificationStatus.get_user_attempts( self.user.id, self.course.id, self.first_checkpoint_location) self.assertEqual(actual_attempts, 1)
def test_add_verification_status(self, status): """ Adding verification status using the class method. """ # adding verification status VerificationStatus.add_verification_status( checkpoint=self.first_checkpoint, user=self.user, status=status) # test the status from database result = VerificationStatus.objects.filter( checkpoint=self.first_checkpoint)[0] self.assertEqual(result.status, status) self.assertEqual(result.user, self.user)
def test_add_verification_status(self, status): """ Adding verification status using the class method. """ # adding verification status VerificationStatus.add_verification_status( checkpoint=self.first_checkpoint, user=self.user, status=status ) # test the status from database result = VerificationStatus.objects.filter(checkpoint=self.first_checkpoint)[0] self.assertEqual(result.status, status) self.assertEqual(result.user, self.user)
def test_get_user_attempts(self): """ Test adding verification status. """ VerificationStatus.add_verification_status( checkpoint=self.first_checkpoint, user=self.user, status='submitted' ) actual_attempts = VerificationStatus.get_user_attempts( self.user.id, self.course.id, self.first_checkpoint_location ) self.assertEqual(actual_attempts, 1)
def test_add_status_from_checkpoints(self, status): """Test verification status for reverification checkpoints after submitting software secure photo verification. """ # add initial verification status for checkpoints initial_status = "submitted" VerificationStatus.add_verification_status( checkpoint=self.first_checkpoint, user=self.user, status=initial_status) VerificationStatus.add_verification_status( checkpoint=self.second_checkpoint, user=self.user, status=initial_status) # now add verification status for multiple checkpoint points VerificationStatus.add_status_from_checkpoints( checkpoints=[self.first_checkpoint, self.second_checkpoint], user=self.user, status=status) # test that verification status entries with new status have been added # for both checkpoints result = VerificationStatus.objects.filter( user=self.user, checkpoint=self.first_checkpoint) self.assertEqual(len(result), len(self.first_checkpoint.checkpoint_status.all())) self.assertEqual( list( result.values_list('checkpoint__checkpoint_location', flat=True)), list( self.first_checkpoint.checkpoint_status.values_list( 'checkpoint__checkpoint_location', flat=True))) result = VerificationStatus.objects.filter( user=self.user, checkpoint=self.second_checkpoint) self.assertEqual(len(result), len(self.second_checkpoint.checkpoint_status.all())) self.assertEqual( list( result.values_list('checkpoint__checkpoint_location', flat=True)), list( self.second_checkpoint.checkpoint_status.values_list( 'checkpoint__checkpoint_location', flat=True)))
def test_get_location_id(self): """ Getting location id for a specific checkpoint. """ # creating software secure attempt against checkpoint self.first_checkpoint.add_verification_attempt(SoftwareSecurePhotoVerification.objects.create(user=self.user)) # add initial verification status for checkpoint VerificationStatus.add_verification_status( checkpoint=self.first_checkpoint, user=self.user, status='submitted', ) attempt = SoftwareSecurePhotoVerification.objects.filter(user=self.user) self.assertIsNotNone(VerificationStatus.get_location_id(attempt)) self.assertEqual(VerificationStatus.get_location_id(None), '')
def test_get_location_id(self): """ Getting location id for a specific checkpoint. """ # creating software secure attempt against checkpoint self.first_checkpoint.add_verification_attempt( SoftwareSecurePhotoVerification.objects.create(user=self.user)) # add initial verification status for checkpoint VerificationStatus.add_verification_status( checkpoint=self.first_checkpoint, user=self.user, status='submitted', ) attempt = SoftwareSecurePhotoVerification.objects.filter( user=self.user) self.assertIsNotNone(VerificationStatus.get_location_id(attempt)) self.assertEqual(VerificationStatus.get_location_id(None), '')
def test_add_status_from_checkpoints(self, status): """Test verification status for reverification checkpoints after submitting software secure photo verification. """ # add initial verification status for checkpoints initial_status = "submitted" VerificationStatus.add_verification_status( checkpoint=self.first_checkpoint, user=self.user, status=initial_status ) VerificationStatus.add_verification_status( checkpoint=self.second_checkpoint, user=self.user, status=initial_status ) # now add verification status for multiple checkpoint points VerificationStatus.add_status_from_checkpoints( checkpoints=[self.first_checkpoint, self.second_checkpoint], user=self.user, status=status ) # test that verification status entries with new status have been added # for both checkpoints result = VerificationStatus.objects.filter(user=self.user, checkpoint=self.first_checkpoint) self.assertEqual(len(result), len(self.first_checkpoint.checkpoint_status.all())) self.assertEqual( list(result.values_list('checkpoint__checkpoint_location', flat=True)), list(self.first_checkpoint.checkpoint_status.values_list('checkpoint__checkpoint_location', flat=True)) ) result = VerificationStatus.objects.filter(user=self.user, checkpoint=self.second_checkpoint) self.assertEqual(len(result), len(self.second_checkpoint.checkpoint_status.all())) self.assertEqual( list(result.values_list('checkpoint__checkpoint_location', flat=True)), list(self.second_checkpoint.checkpoint_status.values_list('checkpoint__checkpoint_location', flat=True)) )