def test_ShouldPassWhenValidPhoneFormat(self): # given phone_ok = "912345678" validator = FormatValidator() # when validator.check_valid_phone(phone_ok) # then self.assertIsNone(validator.error, "Error detected")
def test_ShouldFailWhenNoneAsPhone(self): # given validator = FormatValidator() # when validator.check_valid_phone(None) # then self.assertIsNotNone(validator.error, "No error found, but should!") self.assertEqual(validator.error, "Phone number is None", "Not recognized none phone number")
def test_ShouldFailWhenNotValidPhone(self): # given ko_phone = "_*(" validator = FormatValidator() # when validator.check_valid_phone(ko_phone) # then self.assertIsNotNone(validator.error, "No error found, but should!") self.assertEqual(validator.error, "Phone number error", "Not recognized phone number error")
def test_ShouldFailWhenEmptyPhone(self): # given empty_phone = "" validator = FormatValidator() # when validator.check_valid_phone(empty_phone) # then self.assertIsNotNone(validator.error, "No error found, but should!") self.assertEqual(validator.error, "Phone number is empty", "Not recognized empty phone number")