def test_empty_keys(self): handler = ResponseHandler() handler.country_info = CountryInfoPlaceHolder({ "name": "Egypt", "capital": "Cairo" }) response = handler.get('egypt', '') self.assertEqual(response, handler.invalid_info)
def test_get_true_info(self): handler = ResponseHandler() handler.country_info = CountryInfoPlaceHolder({ "name": "Egypt", "capital": "Cairo" }) response = handler.get('egypt', 'name') self.assertEqual(response['name'], 'Egypt')
def test_get_valid_data(self): handler = ResponseHandler() handler.country_info = CountryInfoPlaceHolder({ "capital": "Cairo", "demonym": "Egyptian" }) response = handler.get('egypt', 'capital,demonym') expected = {"capital": "Cairo", "demonym": "Egyptian"} self.assertEqual(expected, response)
def route_scenario_2(name, keys): handler = ResponseHandler() response = handler.get(name, keys) return response
def test_public_api_error_get(self): handler = ResponseHandler() handler.country_info = CountryInfoPlaceHolder(None) response = handler.get('egypt', 'capital') self.assertEqual(response, handler.public_api_error)