Coverage for cc_modules/tests/cc_patientidnum_tests.py: 100%
21 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-03-25 16:46 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-03-25 16:46 +0000
1"""
2camcops_server/cc_modules/tests/cc_patient_tests.py
4===============================================================================
6 Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
7 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
9 This file is part of CamCOPS.
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.
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.
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/>.
24===============================================================================
26"""
28from camcops_server.cc_modules.cc_testfactories import (
29 NHSPatientIdNumFactory,
30 PatientFactory,
31)
32from camcops_server.cc_modules.cc_unittest import DemoRequestTestCase
35class EquivalenceTests(DemoRequestTestCase):
36 """
37 Tests for the __eq__ method on PatientIdNum.
38 """
40 def test_same_object_true(self) -> None:
41 idnum = NHSPatientIdNumFactory()
43 self.assertEqual(idnum, idnum)
45 def test_same_idnum_true(self) -> None:
46 patient_1 = PatientFactory()
47 patient_2 = PatientFactory()
49 idnum_1 = NHSPatientIdNumFactory(patient=patient_1)
50 idnum_2 = NHSPatientIdNumFactory(
51 patient=patient_2,
52 which_idnum=idnum_1.which_idnum,
53 idnum_value=idnum_1.idnum_value,
54 )
56 self.assertEqual(idnum_1, idnum_2)
58 def test_different_idnum_false(self) -> None:
59 patient_1 = PatientFactory()
60 patient_2 = PatientFactory()
62 idnum_1 = NHSPatientIdNumFactory(patient=patient_1)
63 idnum_2 = NHSPatientIdNumFactory(patient=patient_2)
65 self.assertNotEqual(idnum_1, idnum_2)
67 def test_not_a_patientidnum_false(self) -> None:
68 idnum = NHSPatientIdNumFactory()
69 self.assertNotEqual(idnum, "not a patient")