Пример #1
0
    def test_delete_noop(self, st_mock, gen_mock, del_mock):
        gen_mock().iterator.return_value = itertools.repeat(self.cert, 1)
        st_mock().iterator.return_value = itertools.repeat(self.student, 1)

        cert = CertificatePDF(self.user, self.course_id, self.debug, True,
                              self.file_prefix, self.exclude)
        cert.delete()

        st_mock.assert_called_with()
        gen_mock.assert_called_with(user=self.student,
                                    course_id=self.course_id)
        self.assertEqual(del_mock.call_count, 0)
Пример #2
0
    def test_delete_noop(self, st_mock, gen_mock, del_mock):
        gen_mock().iterator.return_value = itertools.repeat(self.cert, 1)
        st_mock().iterator.return_value = itertools.repeat(self.student, 1)

        cert = CertificatePDF(self.user, self.course_id, self.debug,
                              True, self.file_prefix, self.exclude)
        cert.delete()

        st_mock.assert_called_with()
        gen_mock.assert_called_with(
            user=self.student, course_id=self.course_id)
        self.assertEqual(del_mock.call_count, 0)
Пример #3
0
    def test_delete_response_error(self, st_mock, gen_mock, del_mock):
        gen_mock().iterator.return_value = itertools.repeat(self.cert, 1)
        st_mock().iterator.return_value = itertools.repeat(self.student, 1)

        cert = CertificatePDF(self.user, self.course_id, self.debug, self.noop,
                              self.file_prefix, self.exclude)
        cert.delete()

        st_mock.assert_called_with()
        gen_mock.assert_called_with(user=self.student,
                                    course_id=self.course_id)
        del_mock.assert_called_once_with(self.student.username, self.course_id,
                                         ANY)
Пример #4
0
    def test_delete_response_error(self, st_mock, gen_mock, del_mock):
        gen_mock().iterator.return_value = itertools.repeat(self.cert, 1)
        st_mock().iterator.return_value = itertools.repeat(self.student, 1)

        cert = CertificatePDF(self.user, self.course_id, self.debug,
                              self.noop, self.file_prefix, self.exclude)
        cert.delete()

        st_mock.assert_called_with()
        gen_mock.assert_called_with(
            user=self.student, course_id=self.course_id)
        del_mock.assert_called_once_with(
            self.student.username, self.course_id, ANY)
Пример #5
0
    def test_delete_not_coverd_status(self, st_mock, gen_mock, del_mock):
        cert_dummy = MagicMock()
        cert_dummy.status = CertificateStatuses.notpassing
        gen_mock().iterator.return_value = itertools.repeat(cert_dummy, 1)
        st_mock().iterator.return_value = itertools.repeat(self.student, 1)

        cert = CertificatePDF(self.user, self.course_id, self.debug, self.noop,
                              self.file_prefix, self.exclude)
        cert.delete()

        st_mock.assert_called_with()
        gen_mock.assert_called_with(user=self.student,
                                    course_id=self.course_id)
        self.assertEqual(del_mock.call_count, 0)
Пример #6
0
    def test_delete_not_coverd_status(self, st_mock, gen_mock, del_mock):
        cert_dummy = MagicMock()
        cert_dummy.status = CertificateStatuses.notpassing
        gen_mock().iterator.return_value = itertools.repeat(cert_dummy, 1)
        st_mock().iterator.return_value = itertools.repeat(self.student, 1)

        cert = CertificatePDF(self.user, self.course_id, self.debug,
                              self.noop, self.file_prefix, self.exclude)
        cert.delete()

        st_mock.assert_called_with()
        gen_mock.assert_called_with(
            user=self.student, course_id=self.course_id)
        self.assertEqual(del_mock.call_count, 0)