コード例 #1
0
 def test_with_one_filled_pdf(self, get_parser):
     filled_pdf = factories.FilledPDFFactory()
     PDFService.set_bytes_to_filled_pdfs(self.instance, [filled_pdf])
     get_parser.assert_not_called()
     self.assertTrue(self.instance.pdf)
     filled_pdf.pdf.seek(0)
     self.assertEqual(self.instance.pdf.read(), filled_pdf.pdf.read())
コード例 #2
0
 def test_if_all_apps_have_pdfs(self, fill_pdf):
     app_ids = []
     subs = []
     for i in range(3):
         sub = factories.FormSubmissionWithOrgsFactory(
             organizations=[Organization.objects.get(slug='sf_pubdef')])
         factories.FilledPDFFactory(submission=sub)
         subs.append(sub)
         app_ids.append(sub.applications.first().id)
     fill_pdf.assert_not_called()
コード例 #3
0
 def test_if_one_app(self, set_bytes, fill_pdfs):
     new_sf_sub = factories.FormSubmissionWithOrgsFactory(
         organizations=[Organization.objects.get(slug='sf_pubdef')])
     factories.FilledPDFFactory(submission=new_sf_sub)
     new_sf_app = new_sf_sub.applications.first()
     result = PDFService.create_new_pdf_bundle_for_apps(
         self.sf, [new_sf_app])
     self.assertEqual([new_sf_app], list(result.applications.all()))
     fill_pdfs.assert_called_once_with([new_sf_app.id])
     self.assertEqual(set_bytes.call_count, 1)
コード例 #4
0
 def test_if_some_apps_have_pdfs(self, fill_pdf):
     app_ids = []
     subs = []
     for i in range(3):
         sub = factories.FormSubmissionWithOrgsFactory(
             organizations=[Organization.objects.get(slug='sf_pubdef')])
         subs.append(sub)
         if i < 2:
             factories.FilledPDFFactory(submission=sub)
         app_ids.append(sub.applications.first().id)
     with self.settings(DEFAULT_HOST='www.crazymanes.horse'):
         PDFService.fill_any_unfilled_pdfs_for_app_ids(app_ids)
     fill_pdf.assert_called_once_with(app_ids[2])
コード例 #5
0
 def test_if_multiple_apps(self, set_bytes, fill_pdfs):
     new_sf_subs = [
         factories.FormSubmissionWithOrgsFactory(
             organizations=[Organization.objects.get(slug='sf_pubdef')])
         for i in range(3)
     ]
     for sub in new_sf_subs:
         factories.FilledPDFFactory(submission=sub)
     new_sf_apps = [sub.applications.first() for sub in new_sf_subs]
     new_app_ids = [app.id for app in new_sf_apps]
     result = PDFService.create_new_pdf_bundle_for_apps(
         self.sf, new_sf_apps)
     self.assertEqual(set(new_sf_apps), set(result.applications.all()))
     fill_pdfs.assert_called_once_with(new_app_ids)
     self.assertEqual(set_bytes.call_count, 1)
コード例 #6
0
 def test_if_some_apps_have_pdfs(self, admin_alert, fill_pdf):
     app_ids = []
     subs = []
     for i in range(3):
         sub = factories.FormSubmissionWithOrgsFactory(
             organizations=[Organization.objects.get(slug='sf_pubdef')])
         subs.append(sub)
         if i < 2:
             factories.FilledPDFFactory(submission=sub)
         app_ids.append(sub.applications.first().id)
     PDFService.fill_any_unfilled_pdfs_for_app_ids(app_ids)
     fill_pdf.assert_called_once_with(app_ids[2])
     printed_app = str(subs[2].applications.first())
     admin_alert.assert_called_once_with(
         subject='No FilledPDFs for Applications',
         message='1 apps did not have PDFs:\n{}'.format(printed_app))