forked from GithubBackups/healthchecks
Fix tests -- remove debug code, py2 fix
This commit is contained in:
parent
9e37b22a70
commit
4850c9ff03
@ -21,7 +21,7 @@ class PdfInvoice(canvas.Canvas):
|
|||||||
def linefeed(self):
|
def linefeed(self):
|
||||||
self.head_y -= inch / 8
|
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.head_y -= inch / 24
|
||||||
self.linefeed()
|
self.linefeed()
|
||||||
self.setFont("Helvetica-Bold" if bold else "Helvetica", size)
|
self.setFont("Helvetica-Bold" if bold else "Helvetica", size)
|
||||||
@ -39,7 +39,7 @@ class PdfInvoice(canvas.Canvas):
|
|||||||
self.setLineWidth(inch / 72 / 8)
|
self.setLineWidth(inch / 72 / 8)
|
||||||
self.line(inch * 0.5, self.head_y, W - inch * 0.5, self.head_y)
|
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.head_y -= inch / 8
|
||||||
self.linefeed()
|
self.linefeed()
|
||||||
|
|
||||||
@ -57,21 +57,21 @@ class PdfInvoice(canvas.Canvas):
|
|||||||
invoice_id = "MS-HC-%s" % tx.id.upper()
|
invoice_id = "MS-HC-%s" % tx.id.upper()
|
||||||
self.setTitle(invoice_id)
|
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.linefeed()
|
||||||
self.print("Gaujas iela 4-2")
|
self.text("Gaujas iela 4-2")
|
||||||
self.print("Valmiera, LV-4201, Latvia")
|
self.text("Valmiera, LV-4201, Latvia")
|
||||||
self.print("VAT: LV44103100701")
|
self.text("VAT: LV44103100701")
|
||||||
self.linefeed()
|
self.linefeed()
|
||||||
|
|
||||||
created = f(tx.created_at)
|
created = f(tx.created_at)
|
||||||
self.print("Date Issued: %s" % created, align="right")
|
self.text("Date Issued: %s" % created, align="right")
|
||||||
self.print("Invoice Id: %s" % invoice_id, align="right")
|
self.text("Invoice Id: %s" % invoice_id, align="right")
|
||||||
self.linefeed()
|
self.linefeed()
|
||||||
|
|
||||||
self.hr()
|
self.hr()
|
||||||
self.print_row(["Description", "Start", "End", tx.currency_iso_code],
|
self.row(["Description", "Start", "End", tx.currency_iso_code],
|
||||||
bold=True)
|
bold=True)
|
||||||
self.hr()
|
self.hr()
|
||||||
start = f(tx.subscription_details.billing_period_start_date)
|
start = f(tx.subscription_details.billing_period_start_date)
|
||||||
end = f(tx.subscription_details.billing_period_end_date)
|
end = f(tx.subscription_details.billing_period_end_date)
|
||||||
@ -82,19 +82,19 @@ class PdfInvoice(canvas.Canvas):
|
|||||||
else:
|
else:
|
||||||
amount = "%s %s" % (tx.currency_iso_code, tx.amount)
|
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.hr()
|
||||||
self.print_row(["", "", "", "Total: %s" % amount], bold=True)
|
self.row(["", "", "", "Total: %s" % amount], bold=True)
|
||||||
self.linefeed()
|
self.linefeed()
|
||||||
|
|
||||||
self.print("Bill to:", bold=True)
|
self.text("Bill to:", bold=True)
|
||||||
for s in bill_to.split("\n"):
|
for s in bill_to.split("\n"):
|
||||||
self.print(s.strip())
|
self.text(s.strip())
|
||||||
|
|
||||||
self.linefeed()
|
self.linefeed()
|
||||||
self.print("If you have a credit card on file it will be "
|
self.text("If you have a credit card on file it will be "
|
||||||
"automatically charged within 24 hours.", align="center")
|
"automatically charged within 24 hours.", align="center")
|
||||||
|
|
||||||
self.showPage()
|
self.showPage()
|
||||||
self.save()
|
self.save()
|
||||||
|
@ -31,8 +31,6 @@ class PdfInvoiceTestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
r = self.client.get("/invoice/pdf/abc123/")
|
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("ABC123") in r.content)
|
||||||
self.assertTrue(six.b("alice@example.org") in r.content)
|
self.assertTrue(six.b("alice@example.org") in r.content)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user