QC check
This commit is contained in:
@@ -1,3 +1,2 @@
|
||||
# tests/integration/__init__.py
|
||||
"""Integration tests - multiple components working together."""
|
||||
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
# tests/integration/api/__init__.py
|
||||
"""API integration tests."""
|
||||
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
# tests/integration/api/v1/__init__.py
|
||||
"""API v1 endpoint integration tests."""
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ class TestAdminAPI:
|
||||
|
||||
assert response.status_code == 403
|
||||
assert (
|
||||
"Access denied" in response.json()["detail"]
|
||||
or "admin" in response.json()["detail"].lower()
|
||||
"Access denied" in response.json()["detail"]
|
||||
or "admin" in response.json()["detail"].lower()
|
||||
)
|
||||
|
||||
def test_toggle_user_status_admin(self, client, admin_headers, test_user):
|
||||
@@ -48,7 +48,7 @@ class TestAdminAPI:
|
||||
assert "User not found" in response.json()["detail"]
|
||||
|
||||
def test_toggle_user_status_cannot_deactivate_self(
|
||||
self, client, admin_headers, test_admin
|
||||
self, client, admin_headers, test_admin
|
||||
):
|
||||
"""Test that admin cannot deactivate their own account"""
|
||||
response = client.put(
|
||||
@@ -79,8 +79,8 @@ class TestAdminAPI:
|
||||
|
||||
assert response.status_code == 403
|
||||
assert (
|
||||
"Access denied" in response.json()["detail"]
|
||||
or "admin" in response.json()["detail"].lower()
|
||||
"Access denied" in response.json()["detail"]
|
||||
or "admin" in response.json()["detail"].lower()
|
||||
)
|
||||
|
||||
def test_verify_shop_admin(self, client, admin_headers, test_shop):
|
||||
@@ -120,7 +120,7 @@ class TestAdminAPI:
|
||||
assert "Shop not found" in response.json()["detail"]
|
||||
|
||||
def test_get_marketplace_import_jobs_admin(
|
||||
self, client, admin_headers, test_marketplace_job
|
||||
self, client, admin_headers, test_marketplace_job
|
||||
):
|
||||
"""Test admin getting marketplace import jobs"""
|
||||
response = client.get(
|
||||
@@ -136,7 +136,7 @@ class TestAdminAPI:
|
||||
assert test_marketplace_job.id in job_ids
|
||||
|
||||
def test_get_marketplace_import_jobs_with_filters(
|
||||
self, client, admin_headers, test_marketplace_job
|
||||
self, client, admin_headers, test_marketplace_job
|
||||
):
|
||||
"""Test admin getting marketplace import jobs with filters"""
|
||||
response = client.get(
|
||||
@@ -160,8 +160,8 @@ class TestAdminAPI:
|
||||
|
||||
assert response.status_code == 403
|
||||
assert (
|
||||
"Access denied" in response.json()["detail"]
|
||||
or "admin" in response.json()["detail"].lower()
|
||||
"Access denied" in response.json()["detail"]
|
||||
or "admin" in response.json()["detail"].lower()
|
||||
)
|
||||
|
||||
def test_admin_pagination_users(self, client, admin_headers, test_user, test_admin):
|
||||
|
||||
@@ -79,7 +79,9 @@ class TestPagination:
|
||||
db.commit()
|
||||
|
||||
# Test first page
|
||||
response = client.get("/api/v1/admin/shops?limit=5&skip=0", headers=admin_headers)
|
||||
response = client.get(
|
||||
"/api/v1/admin/shops?limit=5&skip=0", headers=admin_headers
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert len(data["shops"]) == 5
|
||||
|
||||
@@ -3,4 +3,3 @@
|
||||
import pytest
|
||||
|
||||
# Add any integration-specific fixtures here if needed
|
||||
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
# tests/integration/security/__init__.py
|
||||
"""Security integration tests."""
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ class TestAuthentication:
|
||||
print(f"Admin endpoint - Raw: {response.content}")
|
||||
|
||||
# Test 2: Try a regular endpoint that uses get_current_user
|
||||
response2 = client.get("/api/v1/product") # or any endpoint with get_current_user
|
||||
response2 = client.get(
|
||||
"/api/v1/product"
|
||||
) # or any endpoint with get_current_user
|
||||
print(f"Regular endpoint - Status: {response2.status_code}")
|
||||
try:
|
||||
print(f"Regular endpoint - Response: {response2.json()}")
|
||||
|
||||
@@ -36,11 +36,15 @@ class TestAuthorization:
|
||||
response = client.get(endpoint, headers=auth_headers)
|
||||
assert response.status_code == 200 # Regular user should have access
|
||||
|
||||
def test_shop_owner_access_control(self, client, auth_headers, test_shop, other_user):
|
||||
def test_shop_owner_access_control(
|
||||
self, client, auth_headers, test_shop, other_user
|
||||
):
|
||||
"""Test that users can only access their own shops"""
|
||||
# Test accessing own shop (should work)
|
||||
response = client.get(f"/api/v1/shop/{test_shop.shop_code}", headers=auth_headers)
|
||||
response = client.get(
|
||||
f"/api/v1/shop/{test_shop.shop_code}", headers=auth_headers
|
||||
)
|
||||
# Response depends on your implementation - could be 200 or 404 if shop doesn't belong to user
|
||||
|
||||
|
||||
# The exact assertion depends on your shop access control implementation
|
||||
assert response.status_code in [200, 403, 404]
|
||||
|
||||
@@ -50,9 +50,7 @@ class TestInputValidation:
|
||||
"""Test JSON validation for POST requests"""
|
||||
# Test invalid JSON structure
|
||||
response = client.post(
|
||||
"/api/v1/product",
|
||||
headers=auth_headers,
|
||||
content="invalid json content"
|
||||
"/api/v1/product", headers=auth_headers, content="invalid json content"
|
||||
)
|
||||
assert response.status_code == 422 # JSON decode error
|
||||
|
||||
@@ -60,6 +58,6 @@ class TestInputValidation:
|
||||
response = client.post(
|
||||
"/api/v1/product",
|
||||
headers=auth_headers,
|
||||
json={"title": "Test Product"} # Missing required product_id
|
||||
json={"title": "Test Product"}, # Missing required product_id
|
||||
)
|
||||
assert response.status_code == 422 # Validation error
|
||||
|
||||
@@ -7,6 +7,7 @@ import pytest
|
||||
from app.tasks.background_tasks import process_marketplace_import
|
||||
from models.database.marketplace import MarketplaceImportJob
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
@pytest.mark.database
|
||||
@pytest.mark.marketplace
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# tests/test_integration.py
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
@pytest.mark.api
|
||||
@pytest.mark.e2e
|
||||
|
||||
Reference in New Issue
Block a user