def handle(self, *args, **options): call_command('flush', interactive=False) self.stdout.write( self.style.SUCCESS("Destroyed all existing data")) call_command('load_essential_data') self.stdout.write( self.style.SUCCESS( "Loaded organizations, counties, groups, & permissions " "from fixtures")) create_seed_users() self.stdout.write( self.style.SUCCESS("Created fake user profiles")) serialize_seed_users() self.stdout.write( self.style.SUCCESS( "Saved to mock_profiles fixture")) fillable_pdf() self.stdout.write( self.style.SUCCESS( "Load fake fillable pdf")) build_seed_submissions() self.stdout.write( self.style.SUCCESS( "Created fake submissions, bundles, and transfers " "and saved them to fixture files")) for app_id in Application.objects.filter( organization__slug='sf_pubdef' ).values_list('id', flat=True): fill_pdf_for_application(app_id) update_pdf_bundle_for_san_francisco() self.stdout.write( self.style.SUCCESS( "Pre-filled PDFs for San Francisco, including pdf bundle of " "unread apps"))
def add_application_pdfs(application_id): # imports of intake services should be called inside of tasks to prevent # circular imports # note: this is a really bad sign for this code, # no reason it should be this complex from intake.services import pdf_service pdf_service.fill_pdf_for_application(application_id) pdf_service.update_pdf_bundle_for_san_francisco()
def test_if_app_and_fillable_are_okay(self, create_w_bytes, mock_fill): fillable = factories.FillablePDFFactory() mock_fill.return_value = b'yay bytez' PDFService.fill_pdf_for_application(self.app.id) create_w_bytes.assert_called_once_with( pdf_bytes=b'yay bytez', original_pdf=fillable, submission=self.app.form_submission)
def test_if_fillable_pdf_is_empty(self): fillable = factories.FillablePDFFactory() fillable.pdf = None fillable.save() with self.assertRaises(exceptions.MissingFillablePDFError): PDFService.fill_pdf_for_application(self.app.id)
def test_with_no_fillable_pdf(self): with self.assertRaises(exceptions.MissingFillablePDFError): PDFService.fill_pdf_for_application(self.app.id)
def test_if_app_not_found(self): with self.assertRaises(ObjectDoesNotExist): PDFService.fill_pdf_for_application(98761)
def add_application_pdfs(application_id): # imports of intake services should be called inside of tasks to prevent # circular imports import intake.services.pdf_service as PDFService PDFService.fill_pdf_for_application(application_id) PDFService.update_pdf_bundle_for_san_francisco()