From 38da576b69e69e23f9472d13952b8f9c9068906a Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Sun, 1 Feb 2026 18:29:13 -0600 Subject: [PATCH] fix(#147): Fix linting violations in quality gate tests Fixed code review findings: - Removed unused mock_run variables (6 instances) - Fixed line length violations (3 instances) - All ruff checks now pass All 36 tests still passing after fixes. Quality gates: BuildGate, LintGate, TestGate, CoverageGate ready for use. --- apps/coordinator/tests/gates/test_build_gate.py | 6 ++---- .../tests/gates/test_coverage_gate.py | 17 ++++++++++++----- apps/coordinator/tests/gates/test_lint_gate.py | 6 ++---- apps/coordinator/tests/gates/test_test_gate.py | 8 +++----- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/apps/coordinator/tests/gates/test_build_gate.py b/apps/coordinator/tests/gates/test_build_gate.py index 542db01..3f1d04d 100644 --- a/apps/coordinator/tests/gates/test_build_gate.py +++ b/apps/coordinator/tests/gates/test_build_gate.py @@ -3,8 +3,6 @@ import subprocess from unittest.mock import MagicMock, patch -import pytest - from src.gates.build_gate import BuildGate from src.gates.quality_gate import GateResult @@ -48,7 +46,7 @@ class TestBuildGate: "Found 2 errors in 2 files (checked 10 source files)" ) - with patch("subprocess.run", return_value=mock_result) as mock_run: + with patch("subprocess.run", return_value=mock_result): gate = BuildGate() result = gate.check() @@ -65,7 +63,7 @@ class TestBuildGate: # Mock subprocess.run to raise CalledProcessError with patch( "subprocess.run", side_effect=subprocess.CalledProcessError(127, "mypy") - ) as mock_run: + ): gate = BuildGate() result = gate.check() diff --git a/apps/coordinator/tests/gates/test_coverage_gate.py b/apps/coordinator/tests/gates/test_coverage_gate.py index 1957ba5..4868cce 100644 --- a/apps/coordinator/tests/gates/test_coverage_gate.py +++ b/apps/coordinator/tests/gates/test_coverage_gate.py @@ -4,8 +4,6 @@ import json import subprocess from unittest.mock import MagicMock, mock_open, patch -import pytest - from src.gates.coverage_gate import CoverageGate from src.gates.quality_gate import GateResult @@ -81,7 +79,10 @@ class TestCoverageGate: """Test that check() returns passed=False when coverage is below 85%.""" mock_result = MagicMock() mock_result.returncode = 1 # pytest-cov returns 1 when below threshold - mock_result.stdout = "TOTAL 100 20 80%\nFAIL Required test coverage of 85% not reached. Total coverage: 80.00%" + mock_result.stdout = ( + "TOTAL 100 20 80%\n" + "FAIL Required test coverage of 85% not reached. Total coverage: 80.00%" + ) mock_result.stderr = "" coverage_data = {"totals": {"percent_covered": 80.0}} @@ -95,7 +96,10 @@ class TestCoverageGate: # Verify result assert isinstance(result, GateResult) assert result.passed is False - assert "below minimum" in result.message.lower() or "failed" in result.message.lower() + assert ( + "below minimum" in result.message.lower() + or "failed" in result.message.lower() + ) assert result.details["coverage_percent"] < 85.0 assert result.details["minimum_coverage"] == 85.0 @@ -135,7 +139,10 @@ class TestCoverageGate: # Verify result assert isinstance(result, GateResult) assert result.passed is False - assert "no coverage data" in result.message.lower() or "not found" in result.message.lower() + assert ( + "no coverage data" in result.message.lower() + or "not found" in result.message.lower() + ) def test_check_failure_subprocess_error(self) -> None: """Test that check() handles subprocess errors gracefully.""" diff --git a/apps/coordinator/tests/gates/test_lint_gate.py b/apps/coordinator/tests/gates/test_lint_gate.py index 7bee00c..c9189e1 100644 --- a/apps/coordinator/tests/gates/test_lint_gate.py +++ b/apps/coordinator/tests/gates/test_lint_gate.py @@ -3,8 +3,6 @@ import subprocess from unittest.mock import MagicMock, patch -import pytest - from src.gates.lint_gate import LintGate from src.gates.quality_gate import GateResult @@ -49,7 +47,7 @@ class TestLintGate: ) mock_result.stderr = "" - with patch("subprocess.run", return_value=mock_result) as mock_run: + with patch("subprocess.run", return_value=mock_result): gate = LintGate() result = gate.check() @@ -84,7 +82,7 @@ class TestLintGate: # Mock subprocess.run to raise CalledProcessError with patch( "subprocess.run", side_effect=subprocess.CalledProcessError(127, "ruff") - ) as mock_run: + ): gate = LintGate() result = gate.check() diff --git a/apps/coordinator/tests/gates/test_test_gate.py b/apps/coordinator/tests/gates/test_test_gate.py index 26495bb..2425dd1 100644 --- a/apps/coordinator/tests/gates/test_test_gate.py +++ b/apps/coordinator/tests/gates/test_test_gate.py @@ -3,10 +3,8 @@ import subprocess from unittest.mock import MagicMock, patch -import pytest - -from src.gates.test_gate import TestGate from src.gates.quality_gate import GateResult +from src.gates.test_gate import TestGate class TestTestGate: @@ -56,7 +54,7 @@ class TestTestGate: ) mock_result.stderr = "" - with patch("subprocess.run", return_value=mock_result) as mock_run: + with patch("subprocess.run", return_value=mock_result): gate = TestGate() result = gate.check() @@ -110,7 +108,7 @@ class TestTestGate: # Mock subprocess.run to raise CalledProcessError with patch( "subprocess.run", side_effect=subprocess.CalledProcessError(127, "pytest") - ) as mock_run: + ): gate = TestGate() result = gate.check()