Exemplo n.º 1
0
    def test_pdf_generation(self):
        filename = '/tmp/test.pdf'
        url = 'http://www.google.com'
        save_pdf(url, filename=filename)
        self.assertTrue(os.path.exists(filename))
        self.assertTrue(os.path.getsize(filename) > 0)
        os.remove(filename)

        obj = PdfDownloadMixin()
        obj.pdf_authenticate = False
        data = obj._return_pdf(url)
        # Check if PDF contains data
        self.assertTrue(data.len > 0)
Exemplo n.º 2
0
 def test_get_pdf_url(self):
     obj = PdfDownloadMixin()
     rf = RequestFactory()
     req = rf.get('/test/invoice?pdf')
     self.assertEqual(obj.get_pdf_location(), '/tmp/download.pdf')
     obj.get_pdf_url(req)
Exemplo n.º 3
0
 def test_get_pdf_cookie(self):
     obj = PdfDownloadMixin()
     obj.pdf_authenticate = False
     rf = RequestFactory()
     req = rf.get('/test/invoice?pdf')
     self.assertEqual(obj.get_pdf_cookie(req), None)
Exemplo n.º 4
0
 def test_methods(self):
     obj = PdfDownloadMixin()
     self.assertTrue(obj.pdf_authenticate)
     self.assertTrue(obj.pdf_remove_file)
     self.assertEqual(obj.get_pdf_attachment_name(), 'download.pdf')
     self.assertEqual(obj.get_pdf_location(), '/tmp/download.pdf')