waclaw-claw 52f0f8d1bd Add unified search API endpoint /api/v1/search/{hash}
- Create src/api/v1/search.py with search() handler
- Add /search/{hash:str} route to v1 router
- Add tests/test_search_api.py for integration tests

Note: Tests fail until Task 3 initializes search_repository in app state.
2026-04-09 12:40:41 -04:00

29 lines
744 B
Python

"""Tests for Search API endpoint."""
import pytest
from fastapi.testclient import TestClient
from src.app import create_app
app = create_app("")
client = TestClient(app)
@pytest.mark.asyncio
async def test_search_block_hash():
response = client.get("/api/v1/search/0x" + "00" * 32)
# Should return 404 for non-existent block
assert response.status_code == 404
@pytest.mark.asyncio
async def test_search_transaction_hash():
response = client.get("/api/v1/search/0x" + "11" * 32)
# Should return 404 for non-existent transaction
assert response.status_code == 404
@pytest.mark.asyncio
async def test_search_invalid_hash():
response = client.get("/api/v1/search/invalid")
assert response.status_code == 400