def test_get_date_of_birth(self): dob = '22-03-1955' user = User() user.date_of_birth = dob expected_date_of_birth = dt.datetime.strptime(dob, '%d-%m-%Y').isoformat() self.assertEqual(user.date_of_birth, expected_date_of_birth) # Checks getter is set
def test_set_valid_date_of_birth(self): dob = '07-02-1976' user = User() user.date_of_birth = dob expected_date_of_birth = dt.datetime.strptime(dob, '%d-%m-%Y').isoformat() self.assertEqual( user._date_of_birth, expected_date_of_birth) # Checks private var has been set
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_date_of_birth_invalid(self): user = User() with self.assertRaises(ValueError): user.date_of_birth = '10-09/1990'