"""This module holds the views tests of the ``pdf_reporting`` app."""

from django.test import RequestFactory

from mtp.apps.common.tests.test_cases import MTPTestCase
from mtp.apps.pdf_reporting.pdf_report import PDFReport
from mtp.apps.pdf_reporting.views import PDFReportMixin


class PDFReportViewTestCase(MTPTestCase):
    """Test case that tests the ``PDFReportView`` view."""

    class TestPDFReportMixin(PDFReportMixin):
        """Test class."""

        template_name = 'pdf_reporting_testapp/rml_test.rml'
        request = RequestFactory()

        def get_filename(self):
            return "file-test"

    def test_get_pdf_file(self):
        """Test that the `get_pdf_file` method works."""

        context_data = {'foo': 'bar'}
        pdf_file = self.TestPDFReportMixin().get_pdf_report(context_data)
        self.assertIsInstance(pdf_file, PDFReport)
