class TestGenerateDischargeSummaryPDF(TestUtils, unittest.TestCase):
@classmethod
def setUpTestData(cls) -> None:
cls.state = cls.create_state()
cls.district = cls.create_district(cls.state)
cls.local_body = cls.create_local_body(cls.district)
cls.super_user = cls.create_super_user("su", cls.district)
cls.facility = cls.create_facility(cls.super_user, cls.district, cls.local_body)
cls.user = cls.create_user("staff1", cls.district, home_facility=cls.facility)
cls.patient = cls.create_patient(
cls.district, cls.facility, local_body=cls.local_body
)
cls.consultation = cls.create_consultation(cls.patient, cls.facility)
def setUp(self) -> None:
self.client = APIClient()
def test_pdf_generation_success(self):
test_data = {"consultation": self.consultation}
with tempfile.NamedTemporaryFile(suffix=".pdf") as file:
compile_typ(file.name, test_data) # Assuming compile_typ generates the PDF
# Assert that the PDF file exists
self.assertTrue(os.path.exists(file.name))
# Optional: Check PDF size (if size is expected to be non-zero)
self.assertGreater(os.path.getsize(file.name), 0) # Uncomment if needed
I'm not able to access self.consultation - test_data = {"consultation": self.consultation}
actually I'm not able to access any variable I've defined in setUpTestData , not sure why. The similar fuctions elsewhere works perfectly fine