Ejemplo n.º 1
0
 def test_build(self):
     """Builds a PDF and ensures it was properly created"""
     invoice = Invoice(424)
     invoice.pdf_file = 'tests/invoices/build_test.pdf'
     with self.app.app_context():
         invoice.build_pdf()
     self.assertTrue(os.path.isfile('tests/invoices/build_test.pdf'))
     invoice.delete_pdf()
Ejemplo n.º 2
0
 def test_delete_pdf(self):
     """Ensure that a PDF was deleted by checking the file path"""
     invoice = Invoice(424)
     invoice.pdf_file = 'tests/invoices/delete_test.pdf'
     with self.app.app_context():
         invoice.build_pdf()
     invoice.delete_pdf()
     self.assertFalse(os.path.isfile('tests/invoices/build_test.pdf'))
Ejemplo n.º 3
0
 def test_download(self):
     """Ensure the download method returns the file correctly"""
     invoice = Invoice(424)
     invoice.pdf_file = 'tests/invoices/download_test.pdf'
     with self.app.app_context():
         response = invoice.download()
     with open('tests/invoices/download_test.pdf', 'rb') as f:
         self.assertEqual(f.read(), response[0])
     invoice.delete_pdf()