Browse Source

Fix tests -- remove debug code, py2 fix

pull/143/head
Pēteris Caune 7 years ago
parent
commit
4850c9ff03
2 changed files with 16 additions and 18 deletions
  1. +16
    -16
      hc/payments/invoices.py
  2. +0
    -2
      hc/payments/tests/test_pdf_invoice.py

+ 16
- 16
hc/payments/invoices.py View File

@ -21,7 +21,7 @@ class PdfInvoice(canvas.Canvas):
def linefeed(self):
self.head_y -= inch / 8
def print(self, s, align="left", size=10, bold=False):
def text(self, s, align="left", size=10, bold=False):
self.head_y -= inch / 24
self.linefeed()
self.setFont("Helvetica-Bold" if bold else "Helvetica", size)
@ -39,7 +39,7 @@ class PdfInvoice(canvas.Canvas):
self.setLineWidth(inch / 72 / 8)
self.line(inch * 0.5, self.head_y, W - inch * 0.5, self.head_y)
def print_row(self, items, align="left", bold=False, size=10):
def row(self, items, align="left", bold=False, size=10):
self.head_y -= inch / 8
self.linefeed()
@ -57,21 +57,21 @@ class PdfInvoice(canvas.Canvas):
invoice_id = "MS-HC-%s" % tx.id.upper()
self.setTitle(invoice_id)
self.print("SIA Monkey See Monkey Do", size=16)
self.text("SIA Monkey See Monkey Do", size=16)
self.linefeed()
self.print("Gaujas iela 4-2")
self.print("Valmiera, LV-4201, Latvia")
self.print("VAT: LV44103100701")
self.text("Gaujas iela 4-2")
self.text("Valmiera, LV-4201, Latvia")
self.text("VAT: LV44103100701")
self.linefeed()
created = f(tx.created_at)
self.print("Date Issued: %s" % created, align="right")
self.print("Invoice Id: %s" % invoice_id, align="right")
self.text("Date Issued: %s" % created, align="right")
self.text("Invoice Id: %s" % invoice_id, align="right")
self.linefeed()
self.hr()
self.print_row(["Description", "Start", "End", tx.currency_iso_code],
bold=True)
self.row(["Description", "Start", "End", tx.currency_iso_code],
bold=True)
self.hr()
start = f(tx.subscription_details.billing_period_start_date)
end = f(tx.subscription_details.billing_period_end_date)
@ -82,19 +82,19 @@ class PdfInvoice(canvas.Canvas):
else:
amount = "%s %s" % (tx.currency_iso_code, tx.amount)
self.print_row(["healthchecks.io paid plan", start, end, amount])
self.row(["healthchecks.io paid plan", start, end, amount])
self.hr()
self.print_row(["", "", "", "Total: %s" % amount], bold=True)
self.row(["", "", "", "Total: %s" % amount], bold=True)
self.linefeed()
self.print("Bill to:", bold=True)
self.text("Bill to:", bold=True)
for s in bill_to.split("\n"):
self.print(s.strip())
self.text(s.strip())
self.linefeed()
self.print("If you have a credit card on file it will be "
"automatically charged within 24 hours.", align="center")
self.text("If you have a credit card on file it will be "
"automatically charged within 24 hours.", align="center")
self.showPage()
self.save()

+ 0
- 2
hc/payments/tests/test_pdf_invoice.py View File

@ -31,8 +31,6 @@ class PdfInvoiceTestCase(BaseTestCase):
self.client.login(username="[email protected]", password="password")
r = self.client.get("/invoice/pdf/abc123/")
with open("/home/cepe/rez.pdf", "wb") as f:
f.write(r.content)
self.assertTrue(six.b("ABC123") in r.content)
self.assertTrue(six.b("[email protected]") in r.content)


Loading…
Cancel
Save