def test_publish_not_ended(self, st_mock, crs_mock, gen_mock): gen_mock().iterator.return_value = itertools.repeat(self.cert, 1) st_mock().iterator.return_value = itertools.repeat(self.student, 1) crs_mock().has_ended.return_value = False with self.assertRaises(CertPDFException) as e: cert = CertificatePDF(self.user, self.course_id, self.debug, self.noop, self.file_prefix, self.exclude) cert.publish() self.assertEqual(e.exception.message, 'This couse is not ended.') st_mock.assert_called_with() crs_mock.assert_called_with(self.course_id)
def test_publish_with_noop(self, st_mock, crs_mock, gen_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.publish() st_mock.assert_called_with() crs_mock.assert_called_once_with(self.course_id) gen_mock.assert_called_with(user=self.student, course_id=self.course_id, status=CertificateStatuses.generating) self.assertEqual(self.cert.save.call_count, 0)
def test_publish_with_noop(self, st_mock, crs_mock, gen_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.publish() st_mock.assert_called_with() crs_mock.assert_called_once_with(self.course_id) gen_mock.assert_called_with( user=self.student, course_id=self.course_id, status=CertificateStatuses.generating) self.assertEqual(self.cert.save.call_count, 0)