auto-claude: subtask-3-2 - Add test_search_google_reviews for successful API response
Added test_search_google_reviews test in TestBraveSearcherGoogleReviews class that verifies successful Google reviews retrieval via Google Places API: - Mocks complete place lookup with realistic place_id - Mocks full place details response including rating, reviews count, opening hours, and business status - Verifies all expected fields are correctly returned - Validates correct API calls are made with expected parameters Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c057794c64
commit
ee6bc656ef
25
.auto-claude-status
Normal file
25
.auto-claude-status
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"active": true,
|
||||||
|
"spec": "007-https-nordabiznes-pl-audit-gbp-inpi-dane-nie-sa-w-",
|
||||||
|
"state": "building",
|
||||||
|
"subtasks": {
|
||||||
|
"completed": 7,
|
||||||
|
"total": 14,
|
||||||
|
"in_progress": 1,
|
||||||
|
"failed": 0
|
||||||
|
},
|
||||||
|
"phase": {
|
||||||
|
"current": "Unit and Integration Tests",
|
||||||
|
"id": null,
|
||||||
|
"total": 4
|
||||||
|
},
|
||||||
|
"workers": {
|
||||||
|
"active": 0,
|
||||||
|
"max": 1
|
||||||
|
},
|
||||||
|
"session": {
|
||||||
|
"number": 8,
|
||||||
|
"started_at": "2026-01-08T20:23:31.762031"
|
||||||
|
},
|
||||||
|
"last_update": "2026-01-08T20:36:12.863042"
|
||||||
|
}
|
||||||
@ -730,6 +730,50 @@ class TestBraveSearcherGoogleReviews(unittest.TestCase):
|
|||||||
"""Set up test with BraveSearcher instance."""
|
"""Set up test with BraveSearcher instance."""
|
||||||
self.searcher = BraveSearcher(api_key='test_brave_api_key')
|
self.searcher = BraveSearcher(api_key='test_brave_api_key')
|
||||||
|
|
||||||
|
@patch.dict('os.environ', {'GOOGLE_PLACES_API_KEY': 'test_places_key'})
|
||||||
|
@patch.object(GooglePlacesSearcher, 'find_place')
|
||||||
|
@patch.object(GooglePlacesSearcher, 'get_place_details')
|
||||||
|
def test_search_google_reviews(self, mock_details, mock_find):
|
||||||
|
"""Test successful Google reviews retrieval via Places API."""
|
||||||
|
# Mock successful place lookup
|
||||||
|
mock_find.return_value = 'ChIJN1t_tDeuEmsRUsoyG83frY4'
|
||||||
|
|
||||||
|
# Mock complete place details response
|
||||||
|
mock_details.return_value = {
|
||||||
|
'google_rating': 4.7,
|
||||||
|
'google_reviews_count': 156,
|
||||||
|
'opening_hours': {
|
||||||
|
'weekday_text': [
|
||||||
|
'Monday: 8:00 AM – 5:00 PM',
|
||||||
|
'Tuesday: 8:00 AM – 5:00 PM',
|
||||||
|
'Wednesday: 8:00 AM – 5:00 PM',
|
||||||
|
'Thursday: 8:00 AM – 5:00 PM',
|
||||||
|
'Friday: 8:00 AM – 4:00 PM',
|
||||||
|
'Saturday: Closed',
|
||||||
|
'Sunday: Closed',
|
||||||
|
],
|
||||||
|
'open_now': True,
|
||||||
|
'periods': [],
|
||||||
|
},
|
||||||
|
'business_status': 'OPERATIONAL',
|
||||||
|
'formatted_phone': '+48 58 123 4567',
|
||||||
|
'website': 'https://example.com',
|
||||||
|
}
|
||||||
|
|
||||||
|
result = self.searcher.search_google_reviews('Test Company Sp. z o.o.', 'Wejherowo')
|
||||||
|
|
||||||
|
# Verify all fields are correctly returned
|
||||||
|
self.assertEqual(result['google_rating'], 4.7)
|
||||||
|
self.assertEqual(result['google_reviews_count'], 156)
|
||||||
|
self.assertIsNotNone(result['opening_hours'])
|
||||||
|
self.assertTrue(result['opening_hours']['open_now'])
|
||||||
|
self.assertEqual(len(result['opening_hours']['weekday_text']), 7)
|
||||||
|
self.assertEqual(result['business_status'], 'OPERATIONAL')
|
||||||
|
|
||||||
|
# Verify correct API calls were made
|
||||||
|
mock_find.assert_called_once_with('Test Company Sp. z o.o.', 'Wejherowo')
|
||||||
|
mock_details.assert_called_once_with('ChIJN1t_tDeuEmsRUsoyG83frY4')
|
||||||
|
|
||||||
@patch.dict('os.environ', {'GOOGLE_PLACES_API_KEY': 'test_places_key'})
|
@patch.dict('os.environ', {'GOOGLE_PLACES_API_KEY': 'test_places_key'})
|
||||||
@patch.object(GooglePlacesSearcher, 'find_place')
|
@patch.object(GooglePlacesSearcher, 'find_place')
|
||||||
@patch.object(GooglePlacesSearcher, 'get_place_details')
|
@patch.object(GooglePlacesSearcher, 'get_place_details')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user