def test_update_course_exist_requested_preapproved_instid(self): user1 = factories.UserFactory(email="", institutional_id="1234") factories.ParticipationFactory(course=self.course, user=user1, status=participation_status.requested) factories.ParticipationPreapprovalFactory(course=self.course, institutional_id="4321") user2 = factories.UserFactory(email="", institutional_id="2345") factories.ParticipationFactory(course=self.course, user=user2, status=participation_status.requested) factories.ParticipationPreapprovalFactory(course=self.course, institutional_id="2345") with mock.patch(HANDLE_ENROLLMENT_PATH) as mock_handle_enrollment: mock_handle_enrollment.return_value = None self.course.listed = not self.course.listed self.course.save() self.assertEqual(mock_handle_enrollment.call_count, 0) self.course.preapproval_require_verified_inst_id = False self.course.save() self.assertEqual(mock_handle_enrollment.call_count, 1) mock_handle_enrollment.reset_mock() user1.institutional_id = "4321" user1.save() self.assertEqual(mock_handle_enrollment.call_count, 1)
def test_update_course_exist_requested_preapproved(self): user = factories.UserFactory() factories.ParticipationFactory(course=self.course, user=user, status=participation_status.requested) factories.ParticipationPreapprovalFactory(course=self.course, email=user.email) with mock.patch(HANDLE_ENROLLMENT_PATH) as mock_handle_enrollment: mock_handle_enrollment.return_value = None self.course.listed = not self.course.listed self.course.save() self.assertEqual(mock_handle_enrollment.call_count, 1)
def test_update_course_user_not_active(self): user = factories.UserFactory(is_active=False) factories.ParticipationFactory(course=self.course, user=user, status=participation_status.requested) factories.ParticipationPreapprovalFactory(course=self.course, email=user.email) with mock.patch( "course.models.ParticipationPreapproval.objects.get")\ as mock_pprvl_get,\ mock.patch(HANDLE_ENROLLMENT_PATH) as mock_handle_enrollment: self.course.listed = not self.course.listed self.course.save() self.assertEqual(mock_pprvl_get.call_count, 0) self.assertEqual(mock_handle_enrollment.call_count, 0)
def test_unicode(self): paprv1 = factories.ParticipationPreapprovalFactory( course=self.course, institutional_id=None) paprv2 = factories.ParticipationPreapprovalFactory( course=self.course, institutional_id=None) self.assertNotEqual(str(paprv1), str(paprv2)) paprv3 = factories.ParticipationPreapprovalFactory(course=self.course, email=None) paprv4 = factories.ParticipationPreapprovalFactory(course=self.course, email=None) self.assertNotEqual(str(paprv3), str(paprv4)) paprv5 = factories.ParticipationPreapprovalFactory( course=self.course, email=None, institutional_id=None, ) paprv6 = factories.ParticipationPreapprovalFactory( course=self.course, email=None, institutional_id=None, ) self.assertNotEqual(str(paprv5), str(paprv6))
def test_participation_preapproval(self): factories.ParticipationPreapprovalFactory(course=self.course1) self.navigate_admin_view_by_model(models.ParticipationPreapproval)