| """Tests for search.py module.""" | |
| import pytest | |
| from google_play_scraper.features.search import search | |
| from unittest.mock import patch | |
| def test_search_success(mock_get): | |
| mock_get.return_value = { | |
| "results": [ | |
| {"title": "App 1", "appId": "com.app1", "rating": 4.0}, | |
| {"title": "App 2", "appId": "com.app2", "rating": 4.5} | |
| ] | |
| } | |
| results = search("test query") | |
| assert len(results) == 2 | |
| assert results[0]["title"] == "App 1" | |
| def test_search_empty(mock_get): | |
| mock_get.return_value = {"results": []} | |
| results = search("nonexistent") | |
| assert len(results) == 0 |