Ejemplo n.º 1
0
    def test_invalid_image_path(self):
        PDFInvoice(items_data=self.items_data,
                   item_id=self.item_id,
                   date=self.date,
                   is_invoice=self.is_invoice,
                   total_cost=self.total_cost,
                   payment_received=self.payment_received,
                   balance=self.balance).generate_pdf(self.pdf_buffer)

        pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
        self.assertTrue(any('Receipt' in s for s in pdf_content))
Ejemplo n.º 2
0
    def test_invalid_image_path(self):
        PDFInvoice(
            items_data=self.items_data,
            item_id=self.item_id,
            date=self.date,
            is_invoice=self.is_invoice,
            total_cost=self.total_cost,
            payment_received=self.payment_received,
            balance=self.balance
        ).generate_pdf(self.pdf_buffer)

        pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
        self.assertTrue(any('Receipt' in s for s in pdf_content))
Ejemplo n.º 3
0
    def test_pdf_receipt_file_footer_pagination(self):
        for i in range(2, 44):
            self.items_data.append(self.get_item_data(i))

        PDFInvoice(items_data=self.items_data,
                   item_id=self.item_id,
                   date=self.date,
                   is_invoice=self.is_invoice,
                   total_cost=self.total_cost,
                   payment_received=self.payment_received,
                   balance=self.balance).generate_pdf(self.pdf_buffer)

        pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
        self.assertTrue(any('Receipt' in s for s in pdf_content))
Ejemplo n.º 4
0
    def test_pdf_invoice_with_default_settings(self):
        self.is_invoice = True
        PDFInvoice(
            items_data=self.items_data,
            item_id=self.item_id,
            date=self.date,
            is_invoice=self.is_invoice,
            total_cost=self.total_cost,
            payment_received=self.payment_received,
            balance=self.balance
        ).generate_pdf(self.pdf_buffer)

        pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
        self.assertTrue(any(settings.PDF_RECEIPT_TAX_ID in s for s in pdf_content))
        self.assertTrue(any('Invoice' in s for s in pdf_content))
        self.assertTrue(any(settings.PDF_RECEIPT_TERMS_AND_CONDITIONS in s for s in pdf_content))
Ejemplo n.º 5
0
    def test_pdf_invoice_with_default_settings(self):
        self.is_invoice = True
        PDFInvoice(
            items_data=self.items_data,
            item_id=self.item_id,
            date=self.date,
            is_invoice=self.is_invoice,
            total_cost=self.total_cost,
            payment_received=self.payment_received,
            balance=self.balance
        ).generate_pdf(self.pdf_buffer)

        pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
        self.assertTrue(any(settings.PDF_RECEIPT_TAX_ID in s for s in pdf_content))
        self.assertTrue(any('Invoice' in s for s in pdf_content))
        self.assertTrue(any(settings.PDF_RECEIPT_TERMS_AND_CONDITIONS in s for s in pdf_content))
Ejemplo n.º 6
0
    def test_pdf_receipt_file_footer_pagination(self):
        for i in range(2, 44):
            self.items_data.append(self.get_item_data(i))

        PDFInvoice(
            items_data=self.items_data,
            item_id=self.item_id,
            date=self.date,
            is_invoice=self.is_invoice,
            total_cost=self.total_cost,
            payment_received=self.payment_received,
            balance=self.balance
        ).generate_pdf(self.pdf_buffer)

        pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
        self.assertTrue(any('Receipt' in s for s in pdf_content))
Ejemplo n.º 7
0
 def test_pdf_receipt_not_configured_generation(self):
     PDFInvoice(
         items_data=self.items_data,
         item_id=self.item_id,
         date=self.date,
         is_invoice=self.is_invoice,
         total_cost=self.total_cost,
         payment_received=self.payment_received,
         balance=self.balance
     ).generate_pdf(self.pdf_buffer)
     pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
     self.assertTrue(any('Receipt' in s for s in pdf_content))
     self.assertTrue(any(settings.PDF_RECEIPT_DISCLAIMER_TEXT in s for s in pdf_content))
     self.assertTrue(any(settings.PDF_RECEIPT_BILLING_ADDRESS in s for s in pdf_content))
     self.assertTrue(any(settings.PDF_RECEIPT_FOOTER_TEXT in s for s in pdf_content))
     # PDF_RECEIPT_TERMS_AND_CONDITIONS not displayed in the receipt pdf
     self.assertFalse(any(settings.PDF_RECEIPT_TERMS_AND_CONDITIONS in s for s in pdf_content))
Ejemplo n.º 8
0
 def test_pdf_receipt_not_configured_generation(self):
     PDFInvoice(
         items_data=self.items_data,
         item_id=self.item_id,
         date=self.date,
         is_invoice=self.is_invoice,
         total_cost=self.total_cost,
         payment_received=self.payment_received,
         balance=self.balance
     ).generate_pdf(self.pdf_buffer)
     pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
     self.assertTrue(any('Receipt' in s for s in pdf_content))
     self.assertTrue(any(settings.PDF_RECEIPT_DISCLAIMER_TEXT in s for s in pdf_content))
     self.assertTrue(any(settings.PDF_RECEIPT_BILLING_ADDRESS in s for s in pdf_content))
     self.assertTrue(any(settings.PDF_RECEIPT_FOOTER_TEXT in s for s in pdf_content))
     # PDF_RECEIPT_TERMS_AND_CONDITIONS not displayed in the receipt pdf
     self.assertFalse(any(settings.PDF_RECEIPT_TERMS_AND_CONDITIONS in s for s in pdf_content))
Ejemplo n.º 9
0
 def test_pdf_invoice_with_settings_from_patch(self):
     self.is_invoice = True
     PDFInvoice(items_data=self.items_data,
                item_id=self.item_id,
                date=self.date,
                is_invoice=self.is_invoice,
                total_cost=self.total_cost,
                payment_received=self.payment_received,
                balance=self.balance).generate_pdf(self.pdf_buffer)
     pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
     self.assertTrue(any('46-0807740' in s for s in pdf_content))
     self.assertTrue(any('Invoice' in s for s in pdf_content))
     self.assertTrue(any(str(self.total_cost) in s for s in pdf_content))
     self.assertTrue(
         any(str(self.payment_received) in s for s in pdf_content))
     self.assertTrue(any(str(self.balance) in s for s in pdf_content))
     self.assertTrue(any('edX Tax ID' in s for s in pdf_content))
     self.assertTrue(
         any('Enrollments:\nEnrollments must be completed within 7 full'
             ' days from the course start date.\nPayment Terms:\nPayment'
             ' is due immediately.' in s for s in pdf_content))
Ejemplo n.º 10
0
 def test_pdf_invoice_with_settings_from_patch(self):
     self.is_invoice = True
     PDFInvoice(
         items_data=self.items_data,
         item_id=self.item_id,
         date=self.date,
         is_invoice=self.is_invoice,
         total_cost=self.total_cost,
         payment_received=self.payment_received,
         balance=self.balance
     ).generate_pdf(self.pdf_buffer)
     pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
     self.assertTrue(any('46-0807740' in s for s in pdf_content))
     self.assertTrue(any('Invoice' in s for s in pdf_content))
     self.assertTrue(any(str(self.total_cost) in s for s in pdf_content))
     self.assertTrue(any(str(self.payment_received) in s for s in pdf_content))
     self.assertTrue(any(str(self.balance) in s for s in pdf_content))
     self.assertTrue(any('edX Tax ID' in s for s in pdf_content))
     self.assertTrue(any(
         'Enrollments:\nEnrollments must be completed within 7 full'
         ' days from the course start date.\nPayment Terms:\nPayment'
         ' is due immediately.' in s for s in pdf_content))
Ejemplo n.º 11
0
    def test_pdf_receipt_configured_generation(self):
        PDFInvoice(
            items_data=self.items_data,
            item_id=self.item_id,
            date=self.date,
            is_invoice=self.is_invoice,
            total_cost=self.total_cost,
            payment_received=self.payment_received,
            balance=self.balance
        ).generate_pdf(self.pdf_buffer)
        pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
        self.assertTrue(any('Receipt' in s for s in pdf_content))
        self.assertTrue(any(str(self.total_cost) in s for s in pdf_content))
        self.assertTrue(any(str(self.payment_received) in s for s in pdf_content))
        self.assertTrue(any(str(self.balance) in s for s in pdf_content))
        self.assertFalse(any('edX Tax ID' in s for s in pdf_content))

        # PDF_RECEIPT_TERMS_AND_CONDITIONS not displayed in the receipt pdf
        self.assertFalse(any(
            'Enrollments:\nEnrollments must be completed within 7 full days from the course'
            ' start date.\nPayment Terms:\nPayment is due immediately.' in s for s in pdf_content
        ))
        self.assertTrue(any('edX\n141 Portland St.\n9th Floor\nCambridge,\nMA 02139' in s for s in pdf_content))
Ejemplo n.º 12
0
    def test_pdf_receipt_configured_generation(self):
        PDFInvoice(
            items_data=self.items_data,
            item_id=self.item_id,
            date=self.date,
            is_invoice=self.is_invoice,
            total_cost=self.total_cost,
            payment_received=self.payment_received,
            balance=self.balance
        ).generate_pdf(self.pdf_buffer)
        pdf_content = parse_pages(self.pdf_buffer, 'test_pass')
        self.assertTrue(any('Receipt' in s for s in pdf_content))
        self.assertTrue(any(str(self.total_cost) in s for s in pdf_content))
        self.assertTrue(any(str(self.payment_received) in s for s in pdf_content))
        self.assertTrue(any(str(self.balance) in s for s in pdf_content))
        self.assertTrue(any('edX Tax ID' in s for s in pdf_content))

        # PDF_RECEIPT_TERMS_AND_CONDITIONS not displayed in the receipt pdf
        self.assertFalse(any(
            'Enrollments:\nEnrollments must be completed within 7 full days from the course'
            ' start date.\nPayment Terms:\nPayment is due immediately.' in s for s in pdf_content
        ))
        self.assertTrue(any('edX\n141 Portland St.\n9th Floor\nCambridge,\nMA 02139' in s for s in pdf_content))