Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/test_google_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from google_images_search import search_images

def test_search_images(monkeypatch):
# Mock response
class MockResponse:
def json(self):
return {
'items': [
{'link': 'https://example.com/image1.jpg'},
{'link': 'https://example.com/image2.jpg'}
]
}

def mock_get(*args, **kwargs):
return MockResponse()

# Replace requests.get with the mock
monkeypatch.setattr("requests.get", mock_get)

results = search_images("cat", "fake_key", "fake_cse_id")

assert results == [
'https://example.com/image1.jpg',
'https://example.com/image2.jpg'
]