Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
Printing tables¶
This document just tests the print to pdf function.
Side note: Code snippets (lines starting with >>>
) in this document get
tested as part of our development workflow. The following
initialization snippet tells you which demo project is being used in
this document.
>>> from lino import startup
>>> startup('lino_book.projects.noi1e.settings.demo')
>>> from lino.api.doctest import *
>>> # rt.login('robin').show('tickets.ActiveTickets')
>>> settings.SITE.appy_params.update(raiseOnError=True)
>>> test_client.force_login(rt.login('robin').user)
>>> def mytest(k):
... url = 'http://127.0.0.1:8000/api/{0}?an=as_pdf'.format(k)
... res = test_client.get(url, REMOTE_USER='robin')
... assert res.status_code == 200, "Request to {} got status code {}".format(url, res.status_code)
... result = json.loads(res.content)
... assert result['success']
... print(result['open_url'])
>>> mytest("tickets/ActiveTickets")
/media/cache/appypdf/127.0.0.1/tickets.ActiveTickets.pdf
>>> mytest("tickets/AllTickets")
/media/cache/appypdf/127.0.0.1/tickets.AllTickets.pdf