def test_title(self): pdf = PDFUserReviewReport.generate({}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn( PDFUserReviewReport.title, pdf_reader.getPage(0).extractText(), )
def test_title(self): pdf = PDFUserReviewReport.generate({}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn( PDFUserReviewReport.title, pdf_reader.getPage(0).extractText(), )
def test_random_content_not_present(self): pdf = PDFUserReviewReport.generate({}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertNotIn( 'aowdbaef aieuf aef rv a7fv isfv srifv ivf if7va7evada11111', pdf_reader.getPage(0).extractText(), )
def test_random_content_not_present(self): pdf = PDFUserReviewReport.generate({}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertNotIn( "aowdbaef aieuf aef rv a7fv isfv srifv ivf if7va7evada11111", pdf_reader.getPage(0).extractText(), )
def test_report_contact_info_present(self): self.client_post_report_creation() self.client_post_report_prep() pdf = PDFUserReviewReport.generate({"reports": [self.report]}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn(self.report_contact_email, pdf_reader.getPage(1).extractText()) self.assertIn(self.report_contact_phone, pdf_reader.getPage(1).extractText())
def test_matching_id_not_present(self): matching_id = "test1a08daw awd7awgd 1213123" self.create_match(self.user1, matching_id) self.create_match(self.user2, matching_id) pdf = PDFUserReviewReport.generate( {"matches": MatchReport.objects.all()}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertNotIn(matching_id, pdf_reader.getPage(1).extractText()) self.assertNotIn(matching_id, pdf_reader.getPage(2).extractText())
def test_report_page(self): self.client_post_report_creation() pdf = PDFUserReviewReport.generate({ 'reports': [self.report], }) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn( 'Report', pdf_reader.getPage(1).extractText(), )
def test_report_page(self): self.client_post_report_creation() pdf = PDFUserReviewReport.generate({ 'reports': [self.report], }) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn( 'Report', pdf_reader.getPage(1).extractText(), )
def test_contact_info_present(self): matching_id = "test1a08daw awd7awgd 1213123" contact_phone = "555-555-5555" self.create_match(self.user1, matching_id) self.create_match(self.user2, matching_id) self.most_recent_report.contact_phone = contact_phone self.most_recent_report.save() pdf = PDFUserReviewReport.generate( {"matches": MatchReport.objects.all()}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn(contact_phone, pdf_reader.getPage(2).extractText())
def test_title(self): matching_id = 'test1a08daw awd7awgd 1213123' self.create_match(self.user1, matching_id) self.create_match(self.user2, matching_id) pdf = PDFUserReviewReport.generate({ 'matches': MatchReport.objects.all(), }) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn( PDFUserReviewReport.title, pdf_reader.getPage(0).extractText(), )
def test_title(self): matching_id = 'test1a08daw awd7awgd 1213123' self.create_match(self.user1, matching_id) self.create_match(self.user2, matching_id) pdf = PDFUserReviewReport.generate({ 'matches': MatchReport.objects.all(), }) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn( PDFUserReviewReport.title, pdf_reader.getPage(0).extractText(), )
def test_output_file(self): """ for when you want to see what the file looks like $ open UserReviewPDFTest.pdf """ self.client_post_report_creation() self.client_post_report_prep() pdf = PDFUserReviewReport.generate( {"reports": [self.report, self.report]}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) with open("UserReviewPDFTest.pdf", "wb") as _file: dst_pdf = PyPDF2.PdfFileWriter() dst_pdf.appendPagesFromReader(pdf_reader) dst_pdf.write(_file)
def test_two_reports(self): self.client_post_report_creation() self.client_post_report_prep() pdf = PDFUserReviewReport.generate({ 'reports': [self.report, self.report], }) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn( self.report_contact_email, pdf_reader.getPage(2).extractText(), ) self.assertIn( self.report_contact_phone, pdf_reader.getPage(2).extractText(), )
def test_output_file(self): ''' for when you want to see what the file looks like $ open UserReviewPDFTest.pdf ''' self.client_post_report_creation() self.client_post_report_prep() pdf = PDFUserReviewReport.generate({ 'reports': [self.report, self.report], }) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) with open('UserReviewPDFTest.pdf', 'wb') as _file: dst_pdf = PyPDF2.PdfFileWriter() dst_pdf.appendPagesFromReader(pdf_reader) dst_pdf.write(_file)
def test_two_reports(self): self.client_post_report_creation() self.client_post_report_prep() pdf = PDFUserReviewReport.generate({ 'reports': [self.report, self.report], }) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn( self.report_contact_email, pdf_reader.getPage(2).extractText(), ) self.assertIn( self.report_contact_phone, pdf_reader.getPage(2).extractText(), )
def test_contact_info_present(self): matching_id = 'test1a08daw awd7awgd 1213123' contact_phone = '555-555-5555' self.create_match(self.user1, matching_id) self.create_match(self.user2, matching_id) self.most_recent_report.contact_phone = contact_phone self.most_recent_report.save() pdf = PDFUserReviewReport.generate({ 'matches': MatchReport.objects.all(), }) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertIn( contact_phone, pdf_reader.getPage(2).extractText(), )
def test_output_file(self): """ for when you want to see what the file looks like $ open MatchingUserReviewPDFTest.pdf """ matching_id = "test1a08daw awd7awgd 1213123" self.create_match(self.user1, matching_id) self.create_match(self.user2, matching_id) self.most_recent_report.contact_phone = "555-555-5555" self.most_recent_report.save() pdf = PDFUserReviewReport.generate( {"matches": MatchReport.objects.all()}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) with open("MatchingUserReviewPDFTest.pdf", "wb") as _file: dst_pdf = PyPDF2.PdfFileWriter() dst_pdf.appendPagesFromReader(pdf_reader) dst_pdf.write(_file)
def test_output_file(self): ''' for when you want to see what the file looks like $ open MatchingUserReviewPDFTest.pdf ''' matching_id = 'test1a08daw awd7awgd 1213123' self.create_match(self.user1, matching_id) self.create_match(self.user2, matching_id) self.most_recent_report.contact_phone = '555-555-5555' self.most_recent_report.save() pdf = PDFUserReviewReport.generate({ 'matches': MatchReport.objects.all(), }) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) with open('MatchingUserReviewPDFTest.pdf', 'wb') as _file: dst_pdf = PyPDF2.PdfFileWriter() dst_pdf.appendPagesFromReader(pdf_reader) dst_pdf.write(_file)
def send_user_review_nofication( self, reports: list, matches: list, to_addresses: typing.List[str], public_key: str, site_id: int, ): self.context = { 'email_template_name': 'callisto_core/notification/user_review.html', 'email_subject': 'Callisto Report Review Notification', 'to_addresses': to_addresses, 'site_id': site_id, } report_file = PDFUserReviewReport.generate({ 'reports': reports, 'matches': matches, }) self._notification_with_report('', report_file, public_key) self.send()
def send_user_review_nofication( self, reports: list, matches: list, to_addresses: typing.List[str], public_key: str, site_id: int, ): self.context = { 'email_template_name': 'callisto_core/notification/user_review.html', 'email_subject': 'Callisto Report Review Notification', 'to_addresses': to_addresses, 'site_id': site_id, } report_file = PDFUserReviewReport.generate({ 'reports': reports, 'matches': matches, }) self._notification_with_report('', report_file, public_key) self.send()
def send_user_review_nofication( self, reports: list, matches: list, to_addresses: typing.List[str], public_key: str, site_id: int, ): self.context = { "email_template_name": "callisto_core/notification/user_review.html", "email_subject": "Callisto Report Review Notification", "to_addresses": to_addresses, "site_id": site_id, } report_file = PDFUserReviewReport.generate({ "reports": reports, "matches": matches }) self._notification_with_report("", report_file, public_key) self.send()
def test_text_present(self): pdf = PDFUserReviewReport.generate({}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertTrue(pdf_reader.getPage(0).extractText())
def test_text_present(self): pdf = PDFUserReviewReport.generate({}) pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf)) self.assertTrue(pdf_reader.getPage(0).extractText())