def test_create_teacher_and_student_from_baseuser_works(self): user = BaseUserFactory() teacher_count = Teacher.objects.count() student_count = Student.objects.count() user_count = BaseUser.objects.count() self.assertIsNone(user.downcast(Student)) self.assertIsNone(user.downcast(Teacher)) """ First, create a student """ Student.objects.create_from_user(user) self.assertIsNotNone(user.downcast(Student)) self.assertIsNone(user.downcast(Teacher)) self.assertEqual(student_count + 1, Student.objects.count()) self.assertEqual(teacher_count, Teacher.objects.count()) self.assertEqual(user_count, BaseUser.objects.count()) """ Second, create a teacher """ Teacher.objects.create_from_user(user) self.assertIsNotNone(user.downcast(Student)) self.assertIsNotNone(user.downcast(Teacher)) self.assertEqual(student_count + 1, Student.objects.count()) self.assertEqual(teacher_count + 1, Teacher.objects.count()) self.assertEqual(user_count, BaseUser.objects.count())
def setUp(self): self.user = BaseUserFactory() self.unknown_user_email = faker.email() self.url = reverse('api:auth:forgot-password-reset') self.data = { 'user': self.user.email }
def setUp(self): self.course = CourseFactory() self.app_info = ApplicationInfoFactory( course=self.course, start_date=timezone.now().date(), end_date=timezone.now().date() + timezone.timedelta(days=1)) self.user = BaseUserFactory()
def setUp(self): self.test_password = faker.password() self.test_email = faker.email() self.user = BaseUserFactory(email=self.test_email) self.user.set_password(self.test_password) self.user.is_active = True self.user.save() self.login_url = reverse('api:auth:login')
def setUp(self): self.user = BaseUserFactory() self.user.is_active = True self.user.save() self.request = Mock() self.request.user = self.user self.course = CourseFactory() self.view = make_mock_object() self.view.kwargs = {'course_id': self.course.id}
def setUp(self): self.course = CourseFactory() self.week = WeekFactory(course=self.course) self.user = BaseUserFactory() self.student = StudentFactory() add_student(self.course, self.student) self.task = IncludedTaskFactory(course=self.course, week=self.week, gradable=False)
def setUp(self): self.user = BaseUserFactory() self.course = CourseFactory(start_date=timezone.now() + timezone.timedelta(days=5)) self.application_info = ApplicationInfoFactory( course=self.course, start_date=timezone.now() - timezone.timedelta(days=5), end_date=timezone.now() - timezone.timedelta(days=4), start_interview_date=timezone.now() - timezone.timedelta(days=3), end_interview_date=timezone.now() + timezone.timedelta(days=4) ) self.interviewer = Interviewer.objects.create_from_user(self.user) self.interviewer.courses_to_interview.add(self.application_info) self.interviewer.save()
def setUp(self): self.test_email = faker.email() self.test_password = faker.password() self.user = BaseUserFactory(email=self.test_email) self.user.set_password(self.test_password) self.user.save() self.login_url = reverse('api:auth:login') self.logout_url = reverse('api:auth:logout') self.change_password_url = reverse('api:auth:change-password') self.data = { 'email': self.test_email, 'password': self.test_password, }
def setUp(self): self.test_email = faker.email() self.test_password = faker.password() self.user = BaseUserFactory(email=self.test_email) self.user.set_password(self.test_password) self.user.is_active = True self.user.save() self.login_url = reverse('api:auth:login') self.user_detail_url = reverse('api:auth:user-detail') self.data = { 'email': self.test_email, 'password': self.test_password, }
def test_creating_from_baseuser_that_is_not_teacher_and_student_works( self): user = BaseUserFactory() count = Teacher.objects.count() teacher = Teacher.objects.create_from_user(user) self.assertEqual(count + 1, Teacher.objects.count()) self.assertEqual(user.email, teacher.email) self.assertTrue(teacher.user.check_password(BaseUserFactory.password)) self.assertIsNotNone(teacher.user.downcast(Teacher))
def test_user_can_decode_only_own_tokens(self): response1 = self.post(self.login_url, data=self.data) user = BaseUserFactory() user.is_active = True user.passwd = faker.password() user.set_password(user.passwd) user.save() data = { 'email': user.email, 'password': user.passwd, } response2 = self.post(self.login_url, data=data) token_user1 = response1.data['token'] token_user2 = response2.data['token'] self.assertNotEqual(token_user1, token_user2) self.assertNotEqual(self.user.secret_key, user.secret_key) with self.assertRaises(InvalidSignatureError): jwt.decode(token_user1, key=str(user.secret_key)) with self.assertRaises(InvalidSignatureError): jwt.decode(token_user2, key=str(self.user.secret_key)) self.assertEqual( self.user.email, jwt.decode(token_user1, key=str(self.user.secret_key))['email'] ) self.assertEqual( user.email, jwt.decode(token_user2, key=str(user.secret_key))['email'] )
def setUp(self): self.user = BaseUserFactory() self.request = make_mock_object(user=self.user)
def setUp(self): self.interviewer = Interviewer.objects.create_from_user(BaseUserFactory()) self.slot = InterviewerFreeTimeFactory(interviewer=self.interviewer)
def setUp(self): self.user = BaseUserFactory()
def setUp(self): self.user = BaseUserFactory() self.request = Mock() self.request.user = self.user
def setUp(self): self.user = BaseUserFactory() self.user.is_active = True self.user.save() self.request = Mock() self.request.user = self.user
def setUp(self): self.user = BaseUserFactory() self.course = CourseFactory() self.application_info = ApplicationInfoFactory(course=self.course) self.application = ApplicationFactory( application_info=self.application_info, user=self.user)