Skip to content

Commit 7492d1f

Browse files
committed
fix: resolve quality gate failures for PR 8
- Remove pytest timeout flags causing CI failures - Add missing aiohttp dependency for async operations - Fix security vulnerability in hashlib.md5 usage with usedforsecurity=False - Fix FastAPI TestClient configuration for router testing - Remove parallel testing configuration causing instability These changes address the critical quality gate failures preventing CI from passing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: MementoRC (https://github.com/MementoRC)
1 parent bfe3b9b commit 7492d1f

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

pyproject.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pydantic = ">=2.0.0,<3.0.0"
102102
numpy = ">=1.21.0,<2.0.0"
103103
pandas = ">=1.5.0,<3.0.0"
104104
httpx = ">=0.24.0,<1.0.0"
105+
aiohttp = ">=3.8.0,<4.0.0"
105106
toml = ">=0.10.0"
106107
click = ">=8.0.0,<9.0.0"
107108
rich = ">=13.0.0,<14.0.0"
@@ -208,9 +209,9 @@ install-editable = "python -m pip install -e ."
208209
dev-setup = "python -m pip install -e ."
209210

210211
# TIER 1: Core Quality Gates (ZERO-TOLERANCE)
211-
test = { cmd = "pytest tests/ -v --timeout=30 -x", env = { CLAUDECODE = "0" } }
212-
test-fast = { cmd = "pytest tests/unit/ -v --timeout=30 --maxfail=5 -n auto", env = { CLAUDECODE = "0" } }
213-
test-cov = { cmd = "pytest tests/ --cov=src/uckn --cov-report=html --cov-report=term --cov-report=xml --cov-report=json --timeout=60", env = { CLAUDECODE = "0" } }
212+
test = { cmd = "pytest tests/ -v -x", env = { CLAUDECODE = "0" } }
213+
test-fast = { cmd = "pytest tests/unit/ -v --maxfail=5", env = { CLAUDECODE = "0" } }
214+
test-cov = { cmd = "pytest tests/ --cov=src/uckn --cov-report=html --cov-report=term --cov-report=xml --cov-report=json", env = { CLAUDECODE = "0" } }
214215
lint = "ruff check src/ tests/ --select=F,E9"
215216
lint-fix = "ruff check --fix src/ tests/"
216217
format = "ruff format src/ tests/"
@@ -247,8 +248,8 @@ diff-cover = { cmd = "diff-cover coverage.xml", env = { CLAUDECODE = "0" } }
247248
check-all = { depends-on = ["quality", "static-analysis"] }
248249

249250
# CI-specific tasks (optimized for CI environments)
250-
ci-test = { cmd = "pytest tests/ --cov=src/uckn --cov-report=xml --timeout=30 -m 'not slow and not benchmark' --maxfail=3 -x --tb=short", env = { CLAUDECODE = "0", ENVIRONMENT = "ci", CI = "1" } }
251-
ci-test-coverage = { cmd = "pytest tests/unit tests/integration --cov=src/uckn --cov-report=json --cov-report=term --timeout=30 --maxfail=3 --tb=short", env = { CLAUDECODE = "0", ENVIRONMENT = "ci", CI = "1" } }
251+
ci-test = { cmd = "pytest tests/ --cov=src/uckn --cov-report=xml -m 'not slow and not benchmark' --maxfail=3 -x --tb=short", env = { CLAUDECODE = "0", ENVIRONMENT = "ci", CI = "1" } }
252+
ci-test-coverage = { cmd = "pytest tests/unit tests/integration --cov=src/uckn --cov-report=json --cov-report=term --maxfail=3 --tb=short", env = { CLAUDECODE = "0", ENVIRONMENT = "ci", CI = "1" } }
252253
ci-lint = { cmd = "pixi run -e quality ruff check src/ tests/ --output-format=github --select=F,E9", env = { CLAUDECODE = "0" } }
253254
ci-format-check = { cmd = "pixi run -e quality ruff format --check src/ tests/", env = { CLAUDECODE = "0" } }
254255

src/uckn/core/atoms/multi_modal_embeddings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _generate_fake_embedding(self, text: str, dim: int = 384) -> list[float]:
175175
word_features = word_features[:half_dim]
176176

177177
# Create hash-based features for second half
178-
hash_obj = hashlib.md5(text.encode())
178+
hash_obj = hashlib.md5(text.encode(), usedforsecurity=False)
179179
hash_bytes = hash_obj.digest()
180180
hash_features = []
181181

tests/unit/api/test_predictions_router.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
from unittest.mock import Mock, patch
33

44
import pytest
5+
from fastapi import FastAPI
56
from fastapi.testclient import TestClient
67

78
from src.uckn.api.dependencies import get_predictive_issue_detector
89
from src.uckn.api.routers.predictions import router
910
from src.uckn.core.organisms.predictive_issue_detector import PredictiveIssueDetector
1011

11-
# Create a TestClient for the router
12-
client = TestClient(router)
12+
# Create a FastAPI app for testing (routers don't have dependency_overrides)
13+
app = FastAPI()
14+
app.include_router(router)
15+
client = TestClient(app)
1316

1417

1518
@pytest.fixture
@@ -33,11 +36,11 @@ def override_dependency(mock_predictive_issue_detector):
3336
"""
3437
Overrides the get_predictive_issue_detector dependency for testing.
3538
"""
36-
router.dependency_overrides[get_predictive_issue_detector] = (
39+
app.dependency_overrides[get_predictive_issue_detector] = (
3740
lambda: mock_predictive_issue_detector
3841
)
3942
yield
40-
router.dependency_overrides = {} # Clean up after test
43+
app.dependency_overrides = {} # Clean up after test
4144

4245

4346
def test_detect_issues_endpoint_success(mock_predictive_issue_detector):

tests/unit/api/test_workflow_router.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest.mock import AsyncMock, MagicMock, patch
33

44
import pytest
5+
from fastapi import FastAPI
56
from fastapi.testclient import TestClient
67

78
from src.uckn.api.models.patterns import PatternStatus
@@ -41,11 +42,12 @@ def mock_workflow_manager():
4142
@pytest.fixture
4243
def client(mock_workflow_manager):
4344
# Override dependencies for testing
44-
app = TestClient(router)
45+
app = FastAPI()
46+
app.include_router(router)
4547
app.dependency_overrides[get_workflow_manager] = lambda: mock_workflow_manager
4648
app.dependency_overrides[get_current_user_id] = lambda: "test_user"
4749
app.dependency_overrides[get_current_user_roles] = lambda: ["contributor", "admin"]
48-
return app
50+
return TestClient(app)
4951

5052

5153
@pytest.mark.asyncio

0 commit comments

Comments
 (0)