from io import BytesIO

import PyPDF2

from wizard_builder import view_helpers as wizard_builer_helpers

from .. import test_base
from ...reporting import report_delivery

# TODO: generate mock_report_data in wizard builder
mock_report_data = [
    {'food options': ['vegetables', 'apples: red']},
    {'do androids dream of electric sheep?': ['awdad']},
    {'whats on the radios?': ['guitar']},
]


class ReportPDFTest(test_base.ReportFlowHelper):

    def test_report_pdf(self):
        self.client_post_report_creation()
        pdf = report_delivery.report_as_pdf(
            report=self.report,
            data=mock_report_data,
            recipient=None,
        )
        pdf_reader = PyPDF2.PdfFileReader(BytesIO(pdf))

        self.assertIn(
            "Reported by: testing_12",
            pdf_reader.getPage(0).extractText())
        self.assertIn('food options', pdf_reader.getPage(0).extractText())
        self.assertIn('vegetables', pdf_reader.getPage(0).extractText())
        self.assertIn('apples: red', pdf_reader.getPage(0).extractText())
        self.assertIn(
            wizard_builer_helpers.SerializedDataHelper.not_answered_text,
            pdf_reader.getPage(0).extractText(),
        )

@@ -36,74 +36,8 @@
 F2%0A%0A
-from wizard_builder import view_helpers as wizard_builer_helpers%0A%0A
 from
@@ -221,24 +221,58 @@
 es: red'%5D%7D,%0A
+    %7B'eat it now???': %5B'catte'%5D%7D,%0A
     %7B'do and
@@ -1052,94 +1052,24 @@
 tIn(
-%0A            wizard_builer_helpers.SerializedDataHelper.not_answered_text,%0A           
+'eat it now???',
  pdf
@@ -1100,20 +1100,10 @@
 ctText()
-,%0A        
 )%0A

Revert "test not answered text present in report"