def test_pdf_match_report_is_generated(self): match1 = self.create_match(self.user1, 'dummy') match2 = self.create_match(self.user2, 'dummy') report = PDFMatchReport([match1, match2]) output = report.generate_match_report(report_id=1) exported_report = BytesIO(output) pdfReader = PyPDF2.PdfFileReader(exported_report) self.assertIn("Intended for: Title IX Coordinator Tatiana Nine", pdfReader.getPage(0).extractText()) self.assertIn("Submitted by: dummy", pdfReader.getPage(0).extractText()) self.assertIn("Submitted by: ymmud", pdfReader.getPage(0).extractText())
def test_matches_to_school(self): EmailNotification.objects.create(name='match_delivery', subject="test match delivery", body="test match body") match1 = self.create_match(self.user1, 'dummy') match2 = self.create_match(self.user2, 'dummy') report = PDFMatchReport([match1, match2]) report.send_matching_report_to_school() sent_report_id = SentMatchReport.objects.latest('id').get_report_id() self.assertEqual(len(mail.outbox), 1) message = mail.outbox[0] self.assertEqual(message.subject, 'test match delivery') self.assertIn('"Reports" <reports', message.from_email) self.assertEqual(message.attachments[0][0], 'report_%s.pdf.gpg' % sent_report_id)