示例#1
0
    def test_set_gender_male(self):
        gender = 'Male'
        user = User()

        user.gender = gender
        self.assertEqual(user._gender,
                         gender)  # Checks private var has been set
示例#2
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
示例#3
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')
示例#4
0
    def test_get_gender(self):
        gender = 'Male'
        user = User()

        user.gender = gender
        self.assertEqual(user.gender, gender)  # Checks getter is set
示例#5
0
    def test_set_gender_invalid(self):
        gender = 'Something else'
        user = User()

        with self.assertRaises(TypeError):
            user.gender = gender