Coverage for cc_modules/tests/cc_tracker_tests.py: 28%

29 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-30 13:48 +0000

1""" 

2camcops_server/cc_modules/tests/cc_tracker_tests.py 

3 

4=============================================================================== 

5 

6 Copyright (C) 2012, University of Cambridge, Department of Psychiatry. 

7 Created by Rudolf Cardinal (rnc1001@cam.ac.uk). 

8 

9 This file is part of CamCOPS. 

10 

11 CamCOPS is free software: you can redistribute it and/or modify 

12 it under the terms of the GNU General Public License as published by 

13 the Free Software Foundation, either version 3 of the License, or 

14 (at your option) any later version. 

15 

16 CamCOPS is distributed in the hope that it will be useful, 

17 but WITHOUT ANY WARRANTY; without even the implied warranty of 

18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

19 GNU General Public License for more details. 

20 

21 You should have received a copy of the GNU General Public License 

22 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>. 

23 

24=============================================================================== 

25 

26""" 

27 

28from camcops_server.cc_modules.cc_simpleobjects import IdNumReference 

29from camcops_server.cc_modules.cc_taskcollection import TaskFilter 

30from camcops_server.cc_modules.cc_tracker import ClinicalTextView, Tracker 

31from camcops_server.cc_modules.cc_unittest import DemoDatabaseTestCase 

32 

33 

34# ============================================================================= 

35# Unit tests 

36# ============================================================================= 

37 

38 

39class TrackerCtvTests(DemoDatabaseTestCase): 

40 """ 

41 Unit tests. 

42 """ 

43 

44 def setUp(self) -> None: 

45 super().setUp() 

46 

47 self.taskfilter = TaskFilter() 

48 

49 idnum_ref = IdNumReference(which_idnum=0, idnum_value=0) 

50 

51 self.taskfilter.idnum_criteria = [idnum_ref] 

52 self.taskfilter.tasks_with_patient_only = True 

53 

54 def test_tracker(self) -> None: 

55 self.announce("test_tracker") 

56 req = self.req 

57 t = Tracker(req, self.taskfilter) 

58 

59 self.assertIsInstance(t.get_html(), str) 

60 self.assertIsInstance(t.get_pdf(), bytes) 

61 self.assertIsInstance(t.get_pdf_html(), str) 

62 self.assertIsInstance(t.get_xml(), str) 

63 self.assertIsInstance(t.suggested_pdf_filename(), str) 

64 

65 def test_ctv(self) -> None: 

66 self.announce("test_ctv") 

67 req = self.req 

68 c = ClinicalTextView(req, self.taskfilter) 

69 

70 self.assertIsInstance(c.get_html(), str) 

71 self.assertIsInstance(c.get_pdf(), bytes) 

72 self.assertIsInstance(c.get_pdf_html(), str) 

73 self.assertIsInstance(c.get_xml(), str) 

74 self.assertIsInstance(c.suggested_pdf_filename(), str)