Coverage for cc_modules/tests/cc_tracker_tests.py: 30%
30 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-08 23:14 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-08 23:14 +0000
1#!/usr/bin/env python
3"""
4camcops_server/cc_modules/tests/cc_tracker_tests.py
6===============================================================================
8 Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
9 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
11 This file is part of CamCOPS.
13 CamCOPS is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
18 CamCOPS is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
26===============================================================================
28"""
30from camcops_server.cc_modules.cc_simpleobjects import IdNumReference
31from camcops_server.cc_modules.cc_taskcollection import TaskFilter
32from camcops_server.cc_modules.cc_tracker import ClinicalTextView, Tracker
33from camcops_server.cc_modules.cc_unittest import DemoDatabaseTestCase
36# =============================================================================
37# Unit tests
38# =============================================================================
41class TrackerCtvTests(DemoDatabaseTestCase):
42 """
43 Unit tests.
44 """
46 def setUp(self) -> None:
47 super().setUp()
49 self.taskfilter = TaskFilter()
51 idnum_ref = IdNumReference(which_idnum=0, idnum_value=0)
53 self.taskfilter.idnum_criteria = [idnum_ref]
54 self.taskfilter.tasks_with_patient_only = True
56 def test_tracker(self) -> None:
57 self.announce("test_tracker")
58 req = self.req
59 t = Tracker(req, self.taskfilter)
61 self.assertIsInstance(t.get_html(), str)
62 self.assertIsInstance(t.get_pdf(), bytes)
63 self.assertIsInstance(t.get_pdf_html(), str)
64 self.assertIsInstance(t.get_xml(), str)
65 self.assertIsInstance(t.suggested_pdf_filename(), str)
67 def test_ctv(self) -> None:
68 self.announce("test_ctv")
69 req = self.req
70 c = ClinicalTextView(req, self.taskfilter)
72 self.assertIsInstance(c.get_html(), str)
73 self.assertIsInstance(c.get_pdf(), bytes)
74 self.assertIsInstance(c.get_pdf_html(), str)
75 self.assertIsInstance(c.get_xml(), str)
76 self.assertIsInstance(c.suggested_pdf_filename(), str)