fix: resolve CI/CD issues - remove unused imports and fix type mismatches
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from src.analyzers.complexity import ComplexityCalculator
|
||||
from src.analyzers.dependencies import DependencyAnalyzer
|
||||
from src.graph.builder import GraphBuilder, GraphType, GraphNode, NodeType, GraphEdge
|
||||
from src.graph.builder import GraphBuilder, GraphType, GraphNode, NodeType
|
||||
from src.parsers.base import Entity, EntityType
|
||||
|
||||
|
||||
@@ -137,6 +136,21 @@ class TestComplexityCalculator:
|
||||
assert report["total_cyclomatic_complexity"] >= 2
|
||||
assert "complexity_distribution" in report
|
||||
|
||||
def test_complexity_distribution(self):
|
||||
entities = [
|
||||
Entity(
|
||||
name=f"func{i}",
|
||||
entity_type=EntityType.FUNCTION,
|
||||
file_path=Path("/test.py"),
|
||||
start_line=1,
|
||||
end_line=5,
|
||||
code="def func():\n pass",
|
||||
)
|
||||
for i in range(10)
|
||||
]
|
||||
report = self.calculator.calculate_project_complexity(entities)
|
||||
assert report["complexity_distribution"]["low"] == 10
|
||||
|
||||
|
||||
class TestDependencyAnalyzer:
|
||||
def setup_method(self):
|
||||
@@ -172,3 +186,38 @@ class TestDependencyAnalyzer:
|
||||
self.builder.add_node(file_node)
|
||||
layers = self.analyzer.get_architecture_layers()
|
||||
assert "presentation" in layers or "other" in layers
|
||||
|
||||
def test_get_file_dependencies(self):
|
||||
file_node = GraphNode(
|
||||
node_id="file_test.py",
|
||||
node_type=NodeType.FILE,
|
||||
name="test.py",
|
||||
file_path=Path("/test.py"),
|
||||
)
|
||||
self.builder.add_node(file_node)
|
||||
deps = self.analyzer.get_file_dependencies(Path("/test.py"))
|
||||
assert isinstance(deps, list)
|
||||
|
||||
|
||||
class TestComplexityReport:
|
||||
def test_report_creation(self):
|
||||
from src.analyzers.complexity import ComplexityReport
|
||||
report = ComplexityReport(file_path=Path("/test.py"))
|
||||
assert report.file_path == Path("/test.py")
|
||||
assert report.functions == []
|
||||
assert report.classes == []
|
||||
assert report.total_cyclomatic_complexity == 0
|
||||
|
||||
def test_average_complexity_calculation(self):
|
||||
from src.analyzers.complexity import ComplexityReport
|
||||
report = ComplexityReport(file_path=Path("/test.py"))
|
||||
report.functions = [
|
||||
{"complexity_score": 5},
|
||||
{"complexity_score": 10},
|
||||
{"complexity_score": 15},
|
||||
]
|
||||
expected_avg = (5 + 10 + 15) / 3
|
||||
actual_avg = sum(f["complexity_score"] for f in report.functions) / len(
|
||||
report.functions
|
||||
)
|
||||
assert actual_avg == expected_avg
|
||||
|
||||
Reference in New Issue
Block a user