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_any_info(self):
     handler = ResponseHandler()
     handler.country_info = CountryInfoPlaceHolder({
         "name": "Egypt",
         "capital": "Cairo"
     })
     response = handler.get_all_info('egypt')
     self.assertTrue(len(response) > 0)
 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 test_filter_with_invalid_keys(self):
     handler = ResponseHandler()
     handler.country_info = CountryInfoPlaceHolder({
         "capital": "Cairo",
         "demonym": "Egyptian"
     })
     with open('offline_country_info.json') as file:
         info = json.load(file)
     response = handler.filter('capital,invalid_key', info)
     self.assertEqual(handler.invalid_info, 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)