def validate_city_name_or_code(city_selected, dict_of_cities): """ Checks if a given City Code or Name exists or not :param city_selected: Code or Name of the city :param dict_of_cities: :return: Returns City Code if found or False if not """ city_selected = city_selected.upper(); # convert to city code if name is valid city_code_from_selected = City.get_city_code(city_selected, dict_of_cities) if not city_code_from_selected == 'NA': city_selected = city_code_from_selected # check if city code exists in the system if not city_selected in dict_of_cities: print("City does not exist in our system or is not currently served by CSAir") return False else: return city_selected
def test_get_city_code(self): dict_of_cities = prepare_test_data() code = City.get_city_code("london", dict_of_cities) self.assertEqual("LON", code)