def setUp(self):
     self.superuser = get_super_user()
     self.user = UserFactory()
     self.unauthorized_user = UserFactory()
     self.classroom = ClassroomFactory(created_by=self.user)
     self.enrollment = EnrollmentFactory(student=self.user,
                                         classroom=self.classroom)
Beispiel #2
0
    def test_only_a_user_who_created_a_class_can_update_it(self):
        user_1 = UserFactory()
        user_2 = UserFactory()
        class_1 = ClassroomFactory(created_by=user_1)
        class_2 = ClassroomFactory(created_by=user_2)

        self.assertTrue(class_1.can_update(user_1))
        self.assertFalse(class_1.can_update(user_2))

        self.assertFalse(class_2.can_update(user_1))
        self.assertTrue(class_2.can_update(user_2))
    def setUp(self):
        self.user = UserFactory()
        self.user_1 = UserFactory()
        self.user_2 = UserFactory()

        self.classroom = ClassroomFactory(created_by=self.user)

        self.enrollment_1 = EnrollmentFactory(classroom=self.classroom,
                                              student=self.user_1)
        self.enrollment_2 = EnrollmentFactory(classroom=self.classroom,
                                              student=self.user_2)
Beispiel #4
0
    def test_superuser_can_update_any_class(self):
        super_user = get_user_model().objects.create_superuser(
            username='******',
            email='*****@*****.**',
            password='******')
        user_1 = UserFactory()
        user_2 = UserFactory()
        class_1 = ClassroomFactory(created_by=user_1)
        class_2 = ClassroomFactory(created_by=user_2)

        self.assertTrue(class_1.can_update(super_user))
        self.assertTrue(class_2.can_update(super_user))
Beispiel #5
0
    def setUp(self):
        self.superuser = get_super_user()
        self.user_1 = UserFactory()
        self.user_2 = UserFactory()

        self.classroom_1 = ClassroomFactory()
        self.classroom_2 = ClassroomFactory()

        self.enrollment_1 = EnrollmentFactory(student=self.user_1,
                                              classroom=self.classroom_1)
        self.enrollment_2 = EnrollmentFactory(student=self.user_2,
                                              classroom=self.classroom_2)
Beispiel #6
0
    def test_only_the_user_who_created_a_classroom_can_update_it(self):
        user_1 = UserFactory()
        user_2 = UserFactory()
        class_1 = ClassroomFactory(created_by=user_1)
        class_2 = ClassroomFactory(created_by=user_1)
        class_3 = ClassroomFactory(created_by=user_2)

        self.assertEqual(Classroom.objects.count(), 3)
        self.assertTrue(class_1.can_update(user_1))
        self.assertTrue(class_2.can_update(user_1))
        self.assertTrue(class_3.can_update(user_2))

        self.assertFalse(class_1.can_update(user_2))
        self.assertFalse(class_2.can_update(user_2))
        self.assertFalse(class_3.can_update(user_1))
Beispiel #7
0
    def test_classroom_model_creation(self):
        user = UserFactory()
        class_1 = ClassroomFactory(name='Astrophysics', created_by=user)
        class_2 = ClassroomFactory(name='Gravitational Mechanics',
                                   created_by=user)

        self.assertEqual(Classroom.objects.count(), 2)
        self.assertEqual(class_1.created_by, user)
        self.assertEqual(class_2.created_by, user)
        self.assertEqual(class_1.name, 'Astrophysics')
        self.assertEqual(class_2.name, 'Gravitational Mechanics')
Beispiel #8
0
    def setUp(self):
        self.super_user = get_user_model().objects.create_superuser(
            username='******',
            email='*****@*****.**',
            password='******')
        self.user_1 = UserFactory()
        self.user_2 = UserFactory()

        self.classroom_1 = ClassroomFactory()
        self.classroom_2 = ClassroomFactory()

        self.enroll_1 = EnrollmentFactory(student=self.user_1,
                                          classroom=self.classroom_1)
        self.enroll_2 = EnrollmentFactory(student=self.user_2,
                                          classroom=self.classroom_2)

        self.post_1 = PostFactory(author=self.user_1,
                                  classroom=self.classroom_1)
        self.post_2 = PostFactory(author=self.user_2,
                                  classroom=self.classroom_2)
Beispiel #9
0
    def test_valid_enrollment_form_with_new_enrollment_sends_email(self):
        student = UserFactory()
        classroom = ClassroomFactory()

        code = str(classroom.id)
        form = EnrollmentForm({'code': code})

        self.assertTrue(form.is_valid())

        with self.assertLogs('classroom.forms', level='INFO') as cm:
            form.send_mail(student=student, classroom=classroom)

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject, 'Site message')
        self.assertGreaterEqual(len(cm.output), 1)
Beispiel #10
0
 def setUp(self):
     self.user = UserFactory()
     self.classroom = ClassroomFactory()
     self.post_1 = PostFactory(classroom=self.classroom, author=self.user)
     self.post_2 = PostFactory(classroom=self.classroom, author=self.user)
Beispiel #11
0
 def setUp(self):
     self.factory = RequestFactory()
     self.user = UserFactory()
     self.classroom = ClassroomFactory(created_by=self.user)