def test_retries(self): """Test hits API call""" # Set up a mock HTTP server setup_http_server(status=429) # Call API client = GoogleHitsClient(max_retries=1, sleep_time=0.1) with self.assertRaises(requests.exceptions.RetryError): _ = [hit for hit in client.hits(['bitergia'])]
def test_hits(self): """Test hits API call""" # Set up a mock HTTP server setup_http_server() # Call API client = GoogleHitsClient() client.hits(['bitergia']) last_request = httpretty.last_request() self.assertEqual(last_request.path, '/search?q=bitergia') self.assertDictEqual(last_request.querystring, {'q': ['bitergia']}) client.hits(['bitergia', 'grimoirelab']) last_request = httpretty.last_request() self.assertEqual(last_request.path, '/search?q=bitergia+grimoirelab') self.assertDictEqual(last_request.querystring, {'q': ['bitergia grimoirelab']})