mirror of
https://github.com/logos-blockchain/logos-blockchain-block-explorer-template.git
synced 2026-05-18 07:19:27 +00:00
- 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.
29 lines
744 B
Python
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
|