Exemplo n.º 1
0
    def test_string_representation_of_user_invalid(self):
        user = User()
        user.name = 'Ann'
        user.gender = 'Female'
        user.smoker = 'Yes'

        self.assertEqual(
            str(user),
            '')  # Return empty string repr if we are missing some parameters
Exemplo n.º 2
0
    def test_string_representation_of_user(self):
        user = User()
        user.name = 'Patrick'
        user.date_of_birth = '10-10-1988'
        user.gender = 'Male'
        user.smoker = 'No'

        self.assertEqual(
            str(user),
            'Patrick was born on 10-10-1988 and is a Male non-smoker')
Exemplo n.º 3
0
    def test_set_smoker_invalid(self):
        smoker = 'I have not smoked'
        user = User()

        with self.assertRaises(TypeError):
            user.smoker = smoker
Exemplo n.º 4
0
    def test_set_smoker_no(self):
        smoker = 'No'
        user = User()

        user.smoker = smoker
        self.assertFalse(user._is_smoker)  # Checks private var has been set
Exemplo n.º 5
0
    def test_set_smoker_yes(self):
        smoker = 'Yes'
        user = User()

        user.smoker = smoker
        self.assertTrue(user._is_smoker)  # Checks private var has been set
Exemplo n.º 6
0
    def test_get_smoker(self):
        smoker = 'No'
        user = User()

        user.smoker = smoker
        self.assertFalse(user.smoker)  # Checks getter is set