Beispiel #1
0
    def test_activity_state_active_for_4(self) -> None:
        basdai = Basdai()

        with mock.patch.object(basdai, "basdai") as mock_basdai:
            mock_basdai.return_value = 4
            with mock.patch.object(basdai, "wxstring") as mock_wxstring:
                basdai.activity_state(self.request)

        mock_wxstring.assert_called_once_with(self.request, "active")
Beispiel #2
0
    def test_basdai_incomplete_when_a_field_invalid(self) -> None:
        basdai = Basdai()

        basdai.q1 = 11
        basdai.q2 = 0
        basdai.q3 = 0
        basdai.q4 = 0

        basdai.q5 = 0
        basdai.q6 = 0

        self.assertFalse(basdai.is_complete())
Beispiel #3
0
    def test_basdai_complete_when_all_answers_valid(self) -> None:
        basdai = Basdai()

        basdai.q1 = 0
        basdai.q2 = 0
        basdai.q3 = 0
        basdai.q4 = 0

        basdai.q5 = 0
        basdai.q6 = 0

        self.assertTrue(basdai.is_complete())
Beispiel #4
0
    def test_basdai_calculation(self) -> None:
        basdai = Basdai()

        basdai.q1 = 2
        basdai.q2 = 10
        basdai.q3 = 7
        basdai.q4 = 1

        basdai.q5 = 9
        basdai.q6 = 3

        # 2 + 10 + 7 + 1 = 20
        # (9 + 3) / 2 = 6
        # 20 + 6 = 26
        # 26 / 5 = 5.2

        self.assertEqual(basdai.basdai(), 5.2)
Beispiel #5
0
    def test_basdai_none_when_field_none(self) -> None:
        basdai = Basdai()

        self.assertIsNone(basdai.basdai())
Beispiel #6
0
    def test_activity_state_qmark_for_none(self) -> None:
        basdai = Basdai()

        with mock.patch.object(basdai, "basdai") as mock_basdai:
            mock_basdai.return_value = None
            self.assertEqual(basdai.activity_state(self.request), "?")