def test_call_wrapper_404(self): full_url = self.url % '404' with requests_mock.mock() as m: m.get(full_url, text='', status_code=404) with self.assertRaises(IOError): _call_wrapper(full_url)
def test_call_wrapper_invalid_request(self): full_url = self.url % 'invalid' with requests_mock.mock() as m: m.get(full_url, text=invalid_request) with self.assertRaises(GoogleAPIInvalidRequest): _call_wrapper(full_url)
def test_call_wrapper_unknown_error(self): full_url = self.url % 'unknown' with requests_mock.mock() as m: m.get(full_url, text=unknown_error) with self.assertRaises(IOError): _call_wrapper(full_url)
def test_call_wrapper_request_denied(self): full_url = self.url % 'denied' with requests_mock.mock() as m: m.get(full_url, text=request_denied) with self.assertRaises(GoogleAPIRequestDenied): _call_wrapper(full_url)
def test_call_wrapper_exceeded_limit(self): full_url = self.url % 'exceeded' with requests_mock.mock() as m: m.get(full_url, text=over_query_limit) with self.assertRaises(GoogleAPILimitExceeded): _call_wrapper(full_url)
def test_call_wrapper_zero_results(self): full_url = self.url % 'zero' with requests_mock.mock() as m: m.get(full_url, text=zero_results) obs = _call_wrapper(full_url) self.assertEqual(obs, {})
def test_call_wrapper_ok(self): full_url = self.url % 'ok' with requests_mock.mock() as m: m.get(full_url, text=ok) obs = _call_wrapper(full_url) exp = loads(ok)['results'] self.assertEqual(obs, exp)