Add integration tests for global /api/v1/artifacts and /api/v1/tags endpoints
This commit is contained in:
@@ -482,6 +482,102 @@ class TestGlobalUploads:
|
|||||||
assert isinstance(data["pagination"]["has_more"], bool)
|
assert isinstance(data["pagination"]["has_more"], bool)
|
||||||
|
|
||||||
|
|
||||||
|
class TestGlobalArtifacts:
|
||||||
|
"""Tests for global artifacts endpoint."""
|
||||||
|
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_global_artifacts_returns_200(self, integration_client):
|
||||||
|
"""Test global artifacts endpoint returns 200."""
|
||||||
|
response = integration_client.get("/api/v1/artifacts")
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
assert "items" in data
|
||||||
|
assert "pagination" in data
|
||||||
|
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_global_artifacts_pagination(self, integration_client):
|
||||||
|
"""Test global artifacts endpoint respects pagination."""
|
||||||
|
response = integration_client.get("/api/v1/artifacts?limit=5&page=1")
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
assert len(data["items"]) <= 5
|
||||||
|
assert data["pagination"]["limit"] == 5
|
||||||
|
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_global_artifacts_filter_by_size(self, integration_client):
|
||||||
|
"""Test filtering global artifacts by size range."""
|
||||||
|
response = integration_client.get(
|
||||||
|
"/api/v1/artifacts?min_size=1&max_size=1000000"
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
for item in data["items"]:
|
||||||
|
assert 1 <= item["size"] <= 1000000
|
||||||
|
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_global_artifacts_sort_by_size(self, integration_client):
|
||||||
|
"""Test sorting global artifacts by size."""
|
||||||
|
response = integration_client.get("/api/v1/artifacts?sort=size&order=desc")
|
||||||
|
assert response.status_code == 200
|
||||||
|
data = response.json()
|
||||||
|
if len(data["items"]) > 1:
|
||||||
|
sizes = [item["size"] for item in data["items"]]
|
||||||
|
assert sizes == sorted(sizes, reverse=True)
|
||||||
|
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_global_artifacts_invalid_sort_returns_400(self, integration_client):
|
||||||
|
"""Test invalid sort field returns 400."""
|
||||||
|
response = integration_client.get("/api/v1/artifacts?sort=invalid_field")
|
||||||
|
assert response.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
|
class TestGlobalTags:
|
||||||
|
"""Tests for global tags endpoint."""
|
||||||
|
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_global_tags_returns_200(self, integration_client):
|
||||||
|
"""Test global tags endpoint returns 200."""
|
||||||
|
response = integration_client.get("/api/v1/tags")
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
assert "items" in data
|
||||||
|
assert "pagination" in data
|
||||||
|
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_global_tags_pagination(self, integration_client):
|
||||||
|
"""Test global tags endpoint respects pagination."""
|
||||||
|
response = integration_client.get("/api/v1/tags?limit=5&page=1")
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
assert len(data["items"]) <= 5
|
||||||
|
assert data["pagination"]["limit"] == 5
|
||||||
|
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_global_tags_has_project_context(self, integration_client):
|
||||||
|
"""Test global tags response includes project/package context."""
|
||||||
|
response = integration_client.get("/api/v1/tags?limit=1")
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
if len(data["items"]) > 0:
|
||||||
|
item = data["items"][0]
|
||||||
|
assert "project_name" in item
|
||||||
|
assert "package_name" in item
|
||||||
|
assert "artifact_id" in item
|
||||||
|
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_global_tags_search_with_wildcard(self, integration_client):
|
||||||
|
"""Test global tags search supports wildcards."""
|
||||||
|
response = integration_client.get("/api/v1/tags?search=v*")
|
||||||
|
assert response.status_code == 200
|
||||||
|
# Just verify it doesn't error; results may vary
|
||||||
|
|
||||||
|
|
||||||
class TestAuditLogs:
|
class TestAuditLogs:
|
||||||
"""Tests for global audit logs endpoint."""
|
"""Tests for global audit logs endpoint."""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user