Example #1
0
    def test_rapid3_calculation(self) -> None:
        rapid3 = Rapid3()

        # a-j total 13
        # expected FN = 13/3 = 4.3 (1 dp)
        rapid3.q1a = 1
        rapid3.q1b = 2
        rapid3.q1c = 3
        rapid3.q1d = 0
        rapid3.q1e = 1
        rapid3.q1f = 0
        rapid3.q1g = 3
        rapid3.q1h = 0
        rapid3.q1i = 1
        rapid3.q1j = 2

        # k-m not scored formally
        rapid3.q1k = 3
        rapid3.q1l = 0
        rapid3.q1m = 1

        rapid3.q2 = 0.5
        rapid3.q3 = 2.0

        # cumulative = 4.3 + 0.5 + 2.0 = 6.8

        self.assertEqual(rapid3.rapid3(), 6.8)
Example #2
0
    def test_incomplete_when_any_field_invalid(self) -> None:
        all_fields = [
            "q1a",
            "q1b",
            "q1c",
            "q1d",
            "q1e",
            "q1f",
            "q1g",
            "q1h",
            "q1i",
            "q1j",
            "q1k",
            "q1l",
            "q1m",
            "q2",
            "q3",
        ]

        for invalid_field in all_fields:
            rapid3 = Rapid3()

            for field in all_fields:
                setattr(rapid3, field, 0.0)

            setattr(rapid3, invalid_field, 10.5)
            self.assertFalse(
                rapid3.is_complete(),
                msg=f"Failed when setting {invalid_field} invalid",
            )
Example #3
0
    def test_disease_severity_high_for_12point1(self) -> None:
        rapid3 = Rapid3()

        with mock.patch.object(rapid3, "rapid3") as mock_rapid3:
            mock_rapid3.return_value = 12.1
            with mock.patch.object(rapid3, "wxstring") as mock_wxstring:
                rapid3.disease_severity(self.request)

        mock_wxstring.assert_called_once_with(self.request, "high_severity")
Example #4
0
    def test_disease_severity_near_remission_for_3(self) -> None:
        rapid3 = Rapid3()

        with mock.patch.object(rapid3, "rapid3") as mock_rapid3:
            mock_rapid3.return_value = 3.0
            with mock.patch.object(rapid3, "wxstring") as mock_wxstring:
                rapid3.disease_severity(self.request)

        mock_wxstring.assert_called_once_with(self.request, "near_remission")
Example #5
0
    def test_disease_severity_n_a_for_none(self) -> None:
        rapid3 = Rapid3()

        with mock.patch.object(rapid3, "rapid3") as mock_rapid3:
            mock_rapid3.return_value = None
            with mock.patch.object(rapid3, "wxstring") as mock_wxstring:
                rapid3.disease_severity(self.request)

        mock_wxstring.assert_called_once_with(self.request, "n_a")
Example #6
0
    def test_complete_when_all_answers_valid(self) -> None:
        rapid3 = Rapid3()

        rapid3.q1a = 0
        rapid3.q1b = 0
        rapid3.q1c = 0
        rapid3.q1d = 0
        rapid3.q1e = 0
        rapid3.q1f = 0
        rapid3.q1g = 0
        rapid3.q1h = 0
        rapid3.q1i = 0
        rapid3.q1j = 0

        rapid3.q1k = 0
        rapid3.q1l = 0
        rapid3.q1m = 0

        rapid3.q2 = 0.0
        rapid3.q3 = 0.0

        self.assertTrue(rapid3.is_complete())
Example #7
0
    def test_rapid3_none_when_field_none(self) -> None:
        rapid3 = Rapid3()

        self.assertIsNone(rapid3.rapid3())