I'm trying to write a test for a function that returns like this
import pdfkit
to_pdf_file = '/tmp/output.pdf'
from bottle import static_file
css = '/srv/http/http://ift.tt/2yBWYs6'
pdfkit.from_string(render_template("oncall/dayview_pdf_export", values), to_pdf_file, css=css)
filename = "medinet_jourportal_{0}.pdf".format(
MDateTime(selected_date).now().strftime("%Y%m%d_%H%M%S_%f"))
return static_file('output.pdf', root='/tmp', download=filename)
Now I wonder how I can read the generated PDF from an HTTPResponse? I tried testing it like this but it doesn't work:
def test(self):
response = oncall.oncall_daily_pdf_export(self.resources, oncall_customer_id='417', selected_date='20170925', oncall_customer_ids='417')
print("## Data from the test:" + str(response.body))
I want to test that the PDF file is actually generated but I don't know how I do that. I can check the status 200 and that there is a buffered reader but I want to extract actual text from the PDF and check it. How can I do that?
Aucun commentaire:
Enregistrer un commentaire