Skip to content

Commit 82e3b86

Browse files
Fix API path in tests
1 parent 0a56a7e commit 82e3b86

File tree

3 files changed

+36
-44
lines changed

3 files changed

+36
-44
lines changed

archive_query_log/browser/routers/search.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ async def unified_search(
140140
Unified search endpoint for SERPs with pagination.
141141
142142
Examples:
143-
- Basic search: /api/serps?query=climate+change
144-
- With page size: /api/serps?query=climate&page_size=20
145-
- Advanced search: /api/serps?query=climate&year=2024&provider_id=google&page_size=50
146-
- Advanced mode: /api/serps?query="climate change" AND renewable&advanced_mode=true
147-
- Wildcard search: /api/serps?query=climat*&advanced_mode=true
148-
- Boolean search: /api/serps?query=(renewable OR solar) AND energy&advanced_mode=true
143+
- Basic search: /serps?query=climate+change
144+
- With page size: /serps?query=climate&page_size=20
145+
- Advanced search: /serps?query=climate&year=2024&provider_id=google&page_size=50
146+
- Advanced mode: /serps?query="climate change" AND renewable&advanced_mode=true
147+
- Wildcard search: /serps?query=climat*&advanced_mode=true
148+
- Boolean search: /serps?query=(renewable OR solar) AND energy&advanced_mode=true
149149
"""
150150
# Validate page_size and page
151151
valid_sizes = [10, 20, 50, 100, 1000]
@@ -348,9 +348,9 @@ async def compare_serps(
348348
- Statistical summary
349349
350350
Examples:
351-
- Compare 2 SERPs: /api/serps/compare?ids=abc123,def456
352-
- Compare 3 SERPs: /api/serps/compare?ids=abc,def,ghi
353-
- Compare 5 SERPs: /api/serps/compare?ids=id1,id2,id3,id4,id5
351+
- Compare 2 SERPs: /serps/compare?ids=abc123,def456
352+
- Compare 3 SERPs: /serps/compare?ids=abc,def,ghi
353+
- Compare 5 SERPs: /serps/compare?ids=id1,id2,id3,id4,id5
354354
"""
355355
# Parse and validate IDs
356356
serp_ids = [id.strip() for id in ids.split(",") if id.strip()]
@@ -392,8 +392,8 @@ async def get_all_providers(
392392
Get a list of (all) available search providers.
393393
394394
Example:
395-
- Get all providers: /api/providers or /api/providers?size=0
396-
- Limit results: /api/providers?size=uint
395+
- Get all providers: /providers or /providers?size=0
396+
- Limit results: /providers?size=uint
397397
"""
398398
if size < 0:
399399
raise HTTPException(
@@ -416,7 +416,7 @@ async def get_provider_by_id(request: Request, provider_id: str):
416416
Get a single provider document by its ID.
417417
418418
Example:
419-
- Get provider: /api/provider/google
419+
- Get provider: /provider/google
420420
"""
421421
result = await safe_search(aql_service.get_provider_by_id(provider_id))
422422
# Return the raw ES document to stay consistent with other detail endpoints
@@ -447,8 +447,8 @@ async def get_provider_statistics(
447447
- Date histogram of captures over time
448448
449449
Example:
450-
- /api/providers/google/statistics
451-
- /api/providers/google/statistics?interval=week&last_n_months=12
450+
- /providers/google/statistics
451+
- /providers/google/statistics?interval=week&last_n_months=12
452452
"""
453453
result = await safe_search(
454454
aql_service.get_provider_statistics(
@@ -484,8 +484,8 @@ async def get_archive_statistics(
484484
- Date histogram of captures over time
485485
486486
Example:
487-
- /api/archives/https://web.archive.org/web/statistics
488-
- /api/archives/https://web.archive.org/web/statistics?interval=week&last_n_months=12
487+
- /archives/https://web.archive.org/web/statistics
488+
- /archives/https://web.archive.org/web/statistics?interval=week&last_n_months=12
489489
"""
490490
result = await safe_search(
491491
aql_service.get_archive_statistics(
@@ -503,10 +503,10 @@ async def get_archive_statistics(
503503
async def get_archive_by_memento_url(request: Request, archive_id: str):
504504
"""
505505
Get archive metadata by its canonical ID (memento_api_url), matching the
506-
`id` field returned by /api/archives.
506+
`id` field returned by /archives.
507507
508508
This enables stable deep-links without relying on ES internal document IDs.
509-
Example: /api/archives/https://web.archive.org/web
509+
Example: /archives/https://web.archive.org/web
510510
"""
511511
result = await safe_search(aql_service.get_archive_metadata(archive_id))
512512
return result
@@ -523,7 +523,7 @@ async def get_serp_unified(
523523
view: Optional[str] = Query(
524524
None,
525525
description="View mode: raw (default), unbranded, or snapshot. "
526-
"Use /api/serps/{id}/views to see available options.",
526+
"Use /serps/{id}/views to see available options.",
527527
),
528528
include: Optional[str] = Query(
529529
None,
@@ -551,14 +551,14 @@ async def get_serp_unified(
551551
- snapshot: Redirect to web archive memento
552552
553553
Examples:
554-
- Basic: /api/serp/123
555-
- Unbranded view: /api/serp/123?view=unbranded
556-
- Snapshot redirect: /api/serp/123?view=snapshot
557-
- With original URL: /api/serp/123?include=original_url
558-
- With tracking removed: /api/serp/123?include=original_url&remove_tracking=true
559-
- With direct links: /api/serp/123?include=direct_links
560-
- Multiple fields: /api/serp/123?include=memento_url,related,unfurl,direct_links,unbranded
561-
- Related SERPs: /api/serp/123?include=related&related_size=5&same_provider=true
554+
- Basic: /serp/123
555+
- Unbranded view: /serp/123?view=unbranded
556+
- Snapshot redirect: /serp/123?view=snapshot
557+
- With original URL: /serp/123?include=original_url
558+
- With tracking removed: /serp/123?include=original_url&remove_tracking=true
559+
- With direct links: /serp/123?include=direct_links
560+
- Multiple fields: /serp/123?include=memento_url,related,unfurl,direct_links,unbranded
561+
- Related SERPs: /serp/123?include=related&related_size=5&same_provider=true
562562
"""
563563
from archive_query_log.browser.schemas.aql import SERPViewType
564564
from fastapi.responses import RedirectResponse
@@ -679,7 +679,7 @@ async def get_serp_views(request: Request, serp_id: str):
679679
similar to switching between "plain text" and "full HTML" views.
680680
681681
Examples:
682-
- /api/serps/123/views
682+
- /serps/123/views
683683
"""
684684
result = await safe_search(aql_service.get_serp_view_options(serp_id))
685685
return result
@@ -710,8 +710,8 @@ async def list_archives(
710710
- Number of SERPs in this archive
711711
712712
Example:
713-
- /api/archives
714-
- /api/archives?limit=50
713+
- /archives
714+
- /archives?limit=50
715715
"""
716716
# Support legacy "size" param as alias for limit
717717
effective_limit = limit

archive_query_log/browser/services/aql_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ async def get_serp_view_options(serp_id: str) -> dict | None:
12561256
"label": "Full Data",
12571257
"description": "Complete SERP data as archived, including all metadata",
12581258
"available": True,
1259-
"url": f"/api/serps/{serp_id}",
1259+
"url": f"/serps/{serp_id}",
12601260
}
12611261
)
12621262

@@ -1268,7 +1268,7 @@ async def get_serp_view_options(serp_id: str) -> dict | None:
12681268
"label": "Unbranded View",
12691269
"description": "Provider-agnostic normalized view of search results",
12701270
"available": True,
1271-
"url": f"/api/serps/{serp_id}?view=unbranded",
1271+
"url": f"/serps/{serp_id}?view=unbranded",
12721272
}
12731273
)
12741274

tests/browser/test_main.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
"""Tests for Main Application Endpoints"""
1+
"""Tests for main endpoints."""
22

3-
4-
def test_root_endpoint(client):
5-
"""Test the root endpoint returns correct response"""
6-
response = client.get("/")
7-
assert response.status_code == 200
8-
data = response.json()
9-
assert "message" in data
10-
assert data["status"] == "healthy"
3+
from fastapi.testclient import TestClient
114

125

13-
def test_health_check(client):
14-
"""Test health check endpoint"""
6+
def test_health_check(client: TestClient) -> None:
7+
"""Test health check endpoint."""
158
response = client.get("/health")
169
assert response.status_code == 200
17-
assert response.json() == {"status": "ok"}

0 commit comments

Comments
 (0)