mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-03-28 17:42:56 +01:00
- Update .flake8 and pre-commit config to properly use flake8 config - Add B008 to ignored errors (FastAPI Depends pattern) - Add E402 to ignored errors (intentional module-level imports) - Remove unused imports from test files and source files - Fix f-strings without placeholders - Add type annotations to inner async functions - Fix SQLAlchemy execute() to use text() wrapper - Add type: ignore comments for alembic.command imports - Exclude alembic/ directory from mypy in pre-commit - Update mypy overrides for test files to not require type annotations - Fix type annotations for params dicts in web routes - Fix generator return type in test fixtures
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
"""Tests for trace path API routes."""
|
|
|
|
|
|
class TestListTracePaths:
|
|
"""Tests for GET /trace-paths endpoint."""
|
|
|
|
def test_list_trace_paths_empty(self, client_no_auth):
|
|
"""Test listing trace paths when database is empty."""
|
|
response = client_no_auth.get("/api/v1/trace-paths")
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["items"] == []
|
|
assert data["total"] == 0
|
|
|
|
def test_list_trace_paths_with_data(self, client_no_auth, sample_trace_path):
|
|
"""Test listing trace paths with data in database."""
|
|
response = client_no_auth.get("/api/v1/trace-paths")
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert len(data["items"]) == 1
|
|
assert data["total"] == 1
|
|
assert data["items"][0]["path_hashes"] == sample_trace_path.path_hashes
|
|
assert data["items"][0]["hop_count"] == sample_trace_path.hop_count
|
|
|
|
|
|
class TestGetTracePath:
|
|
"""Tests for GET /trace-paths/{id} endpoint."""
|
|
|
|
def test_get_trace_path_success(self, client_no_auth, sample_trace_path):
|
|
"""Test getting a specific trace path."""
|
|
response = client_no_auth.get(f"/api/v1/trace-paths/{sample_trace_path.id}")
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["id"] == sample_trace_path.id
|
|
assert data["path_hashes"] == sample_trace_path.path_hashes
|
|
|
|
def test_get_trace_path_not_found(self, client_no_auth):
|
|
"""Test getting a non-existent trace path."""
|
|
response = client_no_auth.get("/api/v1/trace-paths/nonexistent-id")
|
|
assert response.status_code == 404
|