Coverage for tasks/tests/bmi_tests.py: 38%
16 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 13:48 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 13:48 +0000
1"""
2camcops_server/tasks/tests/bmi_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 unittest import TestCase
30from camcops_server.tasks.bmi import Bmi
33class BmiTests(TestCase):
34 def test_bmi_calculation_for_healthy_mass_and_height(self):
35 bmi = Bmi()
37 bmi.mass_kg = 70.0
38 bmi.height_m = 1.83
40 self.assertAlmostEqual(bmi.bmi(), 20.902, places=3)
42 def test_bmi_none_for_zero_height(self):
43 bmi = Bmi()
45 bmi.mass_kg = 70.0
46 bmi.height_m = 0
48 self.assertIsNone(bmi.bmi())
50 def test_bmi_none_when_not_complete(self):
51 bmi = Bmi()
53 self.assertIsNone(bmi.bmi())