def test_update_file_by_monitors(self):
        """
        Test to update a file by monitors.
        """

        self.client.logout()
        self.client.login(username=self.monitor.username, password='******')
        data = {'title': 'File title updated', 'extension': 'txt'}
        response = self.client.post(self.url, data, follow=True)
        files_url = reverse_lazy('files:list',
                                 kwargs={'slug': self.discipline.slug})
        self.assertRedirects(response, files_url)
        self.file.refresh_from_db()
        self.assertEqual(self.file.title, data['title'])
        check_messages(self,
                       response,
                       tag='alert-success',
                       content='File updated successfully.')
    def test_update_peer_review_by_teacher(self):
        """
        Update peer review weight by teacher
        """

        data = {'peer_review_available': True, 'peer_review_weight': 3}
        self.client.login(username=self.teacher.username, password='******')
        self.assertEqual(self.module.peer_review_available, True)
        self.assertEqual(self.module.peer_review_weight, 1)
        response = self.client.post(self.url, data, follow=True)
        self.assertRedirects(response, self.success_redirect)
        self.module.refresh_from_db()
        self.assertEqual(self.module.peer_review_available, True)
        self.assertEqual(self.module.peer_review_weight, 3)
        check_messages(
            self, response,
            tag='alert-success',
            content="Pair Review updated successfully."
        )
示例#3
0
    def test_create_question_by_user_fail(self):
        """
        User that is not into discipline can not update a question with alternatives.
        """

        self.client.login(username=self.user.username, password='******')
        response = self.client.post(self.url, self.data, follow=True)
        self.question.refresh_from_db()
        for alternative in self.alternatives:
            alternative.refresh_from_db()
        self.assertEqual(self.question.title, "Question")
        self.assertEqual(self.alternatives[0].title, "Alternative")
        self.assertEqual(self.alternatives[0].is_correct, True)
        self.assertEqual(self.alternatives[2].title, "Alternative")
        self.assertEqual(self.alternatives[2].is_correct, False)
        check_messages(self,
                       response,
                       tag='alert-danger',
                       content='You are not authorized to do this action.')
    def test_not_update_peer_review_by_monitor_teacher(self):
        """
        Monitor teacher can not update a peer review
        """

        data = {'peer_review_available': True, 'peer_review_weight': 3}
        self.client.login(username=self.teacher_monitor.username, password='******')
        self.assertEqual(self.module.peer_review_available, True)
        self.assertEqual(self.module.peer_review_weight, 1)
        response = self.client.post(self.url, data, follow=True)
        self.assertRedirects(response, self.redirect_path)
        self.module.refresh_from_db()
        self.assertEqual(self.module.peer_review_available, True)
        self.assertEqual(self.module.peer_review_weight, 1)
        check_messages(
            self, response,
            tag='alert-danger',
            content="You are not authorized to do this action."
        )
    def test_remove_student_by_teacher_ok(self):
        """
        Test to remove specific student from discipline and open the
        discipline again.
        """

        self.client.login(username=self.teacher.username, password='******')
        redirect_url = reverse_lazy('disciplines:students',
                                    kwargs={'slug': self.discipline.slug})
        self.assertEqual(self.discipline.is_closed, True)
        response = self.remove_user(self.students[0].pk, redirect_url, 7, 2)
        check_messages(self,
                       response,
                       tag='alert-success',
                       content='You have removed {0} from {1}'.format(
                           self.students[0].get_short_name(),
                           self.discipline.title))
        self.discipline.refresh_from_db()
        self.assertEqual(self.discipline.is_closed, False)
示例#6
0
    def test_update_password_ok(self):
        """
        Test to edit password with successfully.
        """

        data = {
            'old_password': '******',
            'new_password1': 'test12345678',
            'new_password2': 'test12345678'
        }

        self.client.login(username=self.user.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        self.user.refresh_from_db()
        self.assertTrue(self.user.check_password('test12345678'))
        check_messages(self,
                       response,
                       tag='alert-success',
                       content="Password updated successfully.")
    def test_create_tbl_session_by_monitors(self):
        """
        Test to create a new tbl session by monitors if monitor is a teacher.
        """

        data = {
            'discipline': self.discipline,
            'title': 'TBL session test',
            'description': 'TBL session description'
        }
        self.client.login(username=self.teacher_monitor.username,
                          password='******')
        self.assertEqual(TBLSession.objects.count(), 0)
        response = self.client.post(self.url, data, follow=True)
        self.assertEqual(TBLSession.objects.count(), 1)
        check_messages(self,
                       response,
                       tag="alert-success",
                       content="TBL session created successfully.")
示例#8
0
    def test_teacher_can_not_update_last_datetime(self):
        """
        Teacher can not update a date if the date is not later than today's date.
        """

        self.module.irat_datetime = self.now
        self.module.save()

        now = self.now - timedelta(minutes=5)

        data = {'irat_datetime': now.strftime("%Y-%m-%dT%H:%M")}
        self.client.login(username=self.teacher.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        self.module.refresh_from_db()
        check_messages(
            self, response,
            tag='alert-danger',
            content="iRAT date must to be later than today's date."
        )
示例#9
0
    def test_monitor_can_not_change_group_permission(self):
        """
        Test monitor can't change the group permission.
        """

        self.assertEqual(self.discipline.was_group_provided, False)
        self.client.login(username=self.monitor.username, password='******')
        url = reverse_lazy('groups:provide',
                           kwargs={'slug': self.discipline.slug})
        response = self.client.post(url, follow=True)
        redirect_url = reverse_lazy('disciplines:details',
                                    kwargs={'slug': self.discipline.slug})
        self.assertRedirects(response, redirect_url)
        self.discipline.refresh_from_db()
        self.assertEqual(self.discipline.was_group_provided, False)
        check_messages(self,
                       response,
                       tag='alert-danger',
                       content="You are not authorized to do this action.")
示例#10
0
    def test_student_enter_discipline(self):
        """
        Test to student enter discipline with successfully.
        """

        self.client.logout()
        self.client.login(username=self.student.username, password='******')
        self.assertEqual(self.discipline.students.count(), 8)
        password = {'password': '******'}
        response = self.client.post(self.url, password, follow=True)
        self.assertEqual(self.discipline.students.count(), 9)
        profile_url = reverse_lazy('accounts:profile')
        self.assertRedirects(response, profile_url)
        check_messages(
            self,
            response,
            tag='alert-success',
            content='You have been entered into the discipline: {0}'.format(
                self.discipline.title))
    def test_create_tbl_session_fail(self):
        """
        User can not create a tbl session with invalid fields.
        """

        data = {
            'discipline': self.discipline,
            'title': '',
            'description': 'TBL session description'
        }
        self.client.login(username=self.teacher.username, password='******')
        self.assertEqual(TBLSession.objects.count(), 0)
        response = self.client.post(self.url, data, follow=True)
        self.assertEqual(TBLSession.objects.count(), 0)
        check_messages(
            self,
            response,
            tag="alert-danger",
            content="Invalid fields, please fill in the fields correctly.")
示例#12
0
    def test_update_grade_by_teacher(self):
        """
        Test to update a grade by teacher.
        """

        self.client.login(username=self.teacher.username, password="******")
        data = {'irat': 9.5, 'grat': 10.0, 'practical': 6.5, 'peer_review': 8}
        response = self.client.post(self.url, data, follow=True)
        grades_url = reverse_lazy('grades:list',
                                  kwargs={
                                      'slug': self.discipline.slug,
                                      'pk': self.module.pk
                                  })
        self.assertRedirects(response, grades_url)
        self.grade.refresh_from_db()
        self.assertEqual(self.grade.irat, data['irat'])
        check_messages(self,
                       response,
                       tag='alert-success',
                       content='Grades updated successfully.')
示例#13
0
    def test_teacher_change_group_permission(self):
        """
        Test teacher change the group permission.
        """

        self.assertEqual(self.discipline.was_group_provided, False)
        self.client.login(username=self.teacher.username, password='******')
        url = reverse_lazy(
            'groups:provide',
            kwargs={'slug': self.discipline.slug}
        )
        response = self.client.post(url, follow=True)
        self.assertRedirects(response, self.url)
        self.discipline.refresh_from_db()
        self.assertEqual(self.discipline.was_group_provided, True)
        check_messages(
            self, response,
            tag='alert-success',
            content="Groups available."
        )
示例#14
0
    def teste_to_enter_in_crowded_discipline(self):
        """
        Test student can't get into crowded disciplines because it's closed.
        """

        self.client.logout()
        self.client.login(username=self.student.username, password='******')
        self.assertEqual(self.discipline.is_closed, False)
        self.discipline.students.add(self.students2[0])
        self.discipline.students.add(self.students2[1])
        self.assertEqual(self.discipline.students.count(), 10)
        password = {'password': '******'}
        response = self.client.post(self.url, password, follow=True)
        self.assertEqual(self.discipline.students.count(), 10)
        self.discipline.refresh_from_db()
        self.assertTrue(self.discipline.is_closed)
        check_messages(self,
                       response,
                       tag='alert-danger',
                       content='Crowded discipline.')
示例#15
0
    def test_alternative_answer_with_more_than_four_points(self):
        """
        Test to verify if can insert more than four points in one alternative
        """

        data = {
            'alternative01-score': 5,
            'alternative02-score': 0,
            'alternative03-score': 0,
            'alternative04-score': 0
        }

        self.client.login(username=self.student.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        self.assertRedirects(response, self.redirect_url + "?page=1")
        self.assertEqual(IRATSubmission.objects.count(), 0)
        check_messages(self,
                       response,
                       tag='alert-danger',
                       content="You can only enter from 0 to 4 points")
示例#16
0
    def test_negative_alternative_answer(self):
        """
        Test to verify if can insert alternative answer with negative value
        """

        data = {
            'alternative01-score': 2,
            'alternative02-score': -2,
            'alternative03-score': 0,
            'alternative04-score': 0
        }

        self.client.login(username=self.student.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        self.assertRedirects(response, self.redirect_url + "?page=1")
        self.assertEqual(ExerciseSubmission.objects.count(), 0)
        check_messages(self,
                       response,
                       tag='alert-danger',
                       content="You can only enter from 0 to 4 points")
    def test_monitor_can_not_update_practical_test(self):
        """
        Monitor that is not a teacher can't update practical test
        """

        self.client.login(username=self.monitor.username, password='******')
        self.assertEqual(self.session.practical_weight, 4)
        response = self.client.post(self.url, self.data, follow=True)
        session_url = reverse_lazy('modules:details',
                                   kwargs={
                                       'slug': self.discipline.slug,
                                       'pk': self.session.pk
                                   })
        self.assertRedirects(response, session_url)
        self.session.refresh_from_db()
        self.assertEqual(self.session.practical_weight, 4)
        check_messages(self,
                       response,
                       tag='alert-danger',
                       content="You are not authorized to do this action.")
    def test_update_tbl_session_by_teacher(self):
        """
        Test to update a tbl session by teacher.
        """

        data = {
            'title': "TBL session title updated",
            'description': "TBL session description"
        }
        self.client.login(username=self.teacher.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        sessions_url = reverse_lazy('modules:list',
                                    kwargs={'slug': self.discipline.slug})
        self.assertRedirects(response, sessions_url)
        self.session.refresh_from_db()
        self.assertEqual(self.session.title, data['title'])
        check_messages(self,
                       response,
                       tag='alert-success',
                       content='TBL session updated successfully.')
示例#19
0
    def test_update_grade_by_student_fail(self):
        """
        Student can not update a grade.
        """

        self.client.login(username=self.student.username, password="******")
        data = {'irat': 9.5, 'grat': 10.0, 'practical': 6.5, 'peer_review': 8}
        response = self.client.post(self.url, data, follow=True)
        failure_redirect_path = reverse_lazy('modules:details',
                                             kwargs={
                                                 'slug': self.discipline.slug,
                                                 'pk': self.module.pk
                                             })
        self.assertRedirects(response, failure_redirect_path)
        self.grade.refresh_from_db()
        self.assertEqual(self.grade.irat, 8.0)
        check_messages(self,
                       response,
                       tag='alert-danger',
                       content='You are not authorized to do this action.')
示例#20
0
    def test_not_distribute_all_points(self):
        """
        Test to verify what happend if not distribute four points
        """

        data = {
            'alternative01-score': 2,
            'alternative02-score': 0,
            'alternative03-score': 0,
            'alternative04-score': 1
        }

        self.client.login(username=self.student.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        self.assertRedirects(response, self.redirect_url + "?page=1")
        self.assertEqual(IRATSubmission.objects.count(), 1)
        self.assertEqual(2, IRATSubmission.objects.first().score)
        check_messages(self,
                       response,
                       tag='alert-success',
                       content="Question answered successfully.")
示例#21
0
    def test_create_file_fail(self):
        """
        User can not create a file without a file.
        """

        data = {
            'title': 'File title',
            'description': 'File Description',
            'extension': 'TXT',
            'session': self.module
        }

        self.assertEqual(ModuleFile.objects.count(), 0)
        self.client.login(username=self.monitor.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        self.assertEqual(ModuleFile.objects.count(), 0)
        check_messages(
            self,
            response,
            tag="alert-danger",
            content="Invalid fields, please fill in the fields correctly.")
    def test_teacher_can_update_practical_test(self):
        """
        Teacher can update the practical test, before it being opened.
        """

        self.client.login(username=self.teacher.username, password='******')
        self.assertEqual(self.session.practical_weight, 4)
        response = self.client.post(self.url, self.data, follow=True)
        practical_url = reverse_lazy('practical:details',
                                     kwargs={
                                         'slug': self.discipline.slug,
                                         'pk': self.session.pk
                                     })
        self.assertRedirects(response, practical_url)
        self.session.refresh_from_db()
        self.assertEqual(self.session.practical_weight,
                         self.data['practical_weight'])
        check_messages(self,
                       response,
                       tag='alert-success',
                       content='Practical test updated successfully.')
示例#23
0
    def test_create_group_ok(self):
        """
        Test to create a new group with success.
        """

        data = {
            'title': 'Group',
            'students_limit': 5,
        }

        self.assertEqual(self.discipline.groups.count(), 0)
        self.client.login(username=self.teacher.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        url = reverse_lazy('groups:list',
                           kwargs={'slug': self.discipline.slug})
        self.assertRedirects(response, url)
        self.assertEqual(self.discipline.groups.count(), 1)
        check_messages(self,
                       response,
                       tag='alert-success',
                       content="Group created successfully.")
    def test_delete_file_by_teacher(self):
        """
        Test to delete a file by teacher.
        """

        self.assertEqual(ModuleFile.objects.count(), 1)
        response = self.client.post(self.url, follow=True)
        files_url = reverse_lazy(
            'files:module-list',
            kwargs={
                'slug': self.discipline.slug,
                'pk': self.module.pk
            }
        )
        self.assertRedirects(response, files_url)
        self.assertEqual(ModuleFile.objects.count(), 0)
        check_messages(
            self, response,
            tag='alert-success',
            content="File deleted successfully."
        )
    def test_alternative_answer_incorrect_input(self):
        """
        Test to verify if can insert more than four points
        """

        data = {
            'alternative01-score': 4,
            'alternative02-score': 4,
            'alternative03-score': 4,
            'alternative04-score': 4
        }

        self.client.login(username=self.student.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        self.assertRedirects(response, self.redirect_url + "?page=1")
        self.assertEqual(GRATSubmission.objects.count(), 0)
        check_messages(
            self, response,
            tag='alert-danger',
            content="You can't repeat the options."
        )
示例#26
0
    def test_create_group_by_monitor(self):
        """
        Monitor can't create a group.
        """

        data = {
            'title': 'Group',
            'students_limit': 5,
        }

        self.assertEqual(self.discipline.groups.count(), 0)
        self.client.login(username=self.monitor.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        url = reverse_lazy('disciplines:details',
                           kwargs={'slug': self.discipline.slug})
        self.assertRedirects(response, url)
        self.assertEqual(self.discipline.groups.count(), 0)
        check_messages(self,
                       response,
                       tag='alert-danger',
                       content="You are not authorized to do this action.")
    def test_correct_answer_student_no_group(self):
        """
        Test to get the get an message error if student is not inside into a group.
        """

        data = {
            'alternative01-score': 4,
            'alternative02-score': 2,
            'alternative03-score': 1,
            'alternative04-score': 0
        }

        self.client.login(username=self.student_no_group.username, password='******')
        response = self.client.post(self.url, data, follow=True)
        self.assertRedirects(response, self.redirect_url + "?page=1")
        self.assertEqual(GRATSubmission.objects.count(), 0)
        check_messages(
            self, response,
            tag='alert-danger',
            content="Student must be in a group to answer the test."
        )
示例#28
0
    def test_reset_password_ok(self):
        """
        Teste to reset password after receive the link in email.
        """

        reset_password = PasswordReset.objects.create(user=self.user,
                                                      key='12345')
        url = reverse_lazy('accounts:reset-password-confirm',
                           kwargs={'key': reset_password.key})
        data = {
            'old_password': '******',
            'new_password1': 'test12345678',
            'new_password2': 'test12345678'
        }
        response = self.client.post(url, data, follow=True)
        self.user.refresh_from_db()
        self.assertTrue(self.user.check_password('test12345678'))
        check_messages(self,
                       response,
                       tag='alert-success',
                       content="Your password was successfully updated.")
    def test_submit_to_member_out_group(self):
        """
        submit a peer review to a member out of group.
        """

        data = {'score': 88, 'comment': "Ola fulano"}

        url = reverse_lazy('peer_review:answer-review',
                           kwargs={
                               'slug': self.discipline.slug,
                               'pk': self.module.pk,
                               'student_id': self.student3.pk,
                               'peer_review_page': 1
                           })

        self.client.login(username=self.student1.username, password='******')
        response = self.client.post(url, data, follow=True)
        self.assertEqual(PeerReviewSubmission.objects.count(), 0)
        check_messages(self,
                       response,
                       tag='alert-danger',
                       content="You are not authorized to do this action.")
示例#30
0
    def test_teacher_can_update_irat(self):
        """
        Only teacher can update iRAT test.
        """

        data = {
            'irat_weight': 5,
            'irat_duration': 10
        }
        self.client.login(username=self.teacher.username, password='******')
        self.assertEqual(self.module.irat_weight, 3)
        self.assertEqual(self.module.irat_duration, 30)
        response = self.client.post(self.url, data, follow=True)
        self.assertRedirects(response, self.success_url)
        self.module.refresh_from_db()
        self.assertEqual(self.module.irat_weight, 5)
        self.assertEqual(self.module.irat_duration, 10)
        check_messages(
            self, response,
            tag='alert-success',
            content="iRAT updated successfully."
        )