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
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')
def test_set_smoker_invalid(self): smoker = 'I have not smoked' user = User() with self.assertRaises(TypeError): user.smoker = smoker
def test_set_smoker_no(self): smoker = 'No' user = User() user.smoker = smoker self.assertFalse(user._is_smoker) # Checks private var has been set
def test_set_smoker_yes(self): smoker = 'Yes' user = User() user.smoker = smoker self.assertTrue(user._is_smoker) # Checks private var has been set
def test_get_smoker(self): smoker = 'No' user = User() user.smoker = smoker self.assertFalse(user.smoker) # Checks getter is set