@@ -46,14 +46,23 @@ def test_repo(tmp_path):
4646
4747
4848@pytest .fixture
49- def mock_assessment ():
49+ def mock_assessment (tmp_path ):
5050 """Create a mock assessment for testing."""
51+ from datetime import datetime
52+
5153 from agentready .models .assessment import Assessment
54+ from agentready .models .attribute import Attribute
55+ from agentready .models .finding import Finding
5256 from agentready .models .repository import Repository
5357
58+ # Create a temporary directory with .git for Repository validation
59+ test_repo_path = tmp_path / "test-repo"
60+ test_repo_path .mkdir ()
61+ (test_repo_path / ".git" ).mkdir ()
62+
5463 repo = Repository (
5564 name = "test-repo" ,
56- path = Path ( "/tmp/test" ) ,
65+ path = test_repo_path ,
5766 url = None ,
5867 branch = "main" ,
5968 commit_hash = "abc123" ,
@@ -62,14 +71,40 @@ def mock_assessment():
6271 total_lines = 100 ,
6372 )
6473
74+ # Create 25 dummy findings to match attributes_total requirement
75+ findings = []
76+ for i in range (25 ):
77+ attr = Attribute (
78+ id = f"attr_{ i } " ,
79+ name = f"Attribute { i } " ,
80+ category = "Testing" ,
81+ tier = 1 ,
82+ description = "Test attribute" ,
83+ criteria = "Test criteria" ,
84+ default_weight = 0.5 ,
85+ )
86+ finding = Finding (
87+ attribute = attr ,
88+ status = "pass" if i < 20 else "not_applicable" ,
89+ score = 100.0 if i < 20 else 0.0 ,
90+ measured_value = "present" ,
91+ threshold = "present" ,
92+ evidence = [f"Test evidence { i } " ],
93+ remediation = None ,
94+ error_message = None ,
95+ )
96+ findings .append (finding )
97+
6598 assessment = Assessment (
6699 repository = repo ,
67- findings = [],
100+ timestamp = datetime .now (),
101+ findings = findings ,
68102 overall_score = 85.0 ,
69103 certification_level = "Gold" ,
70104 attributes_assessed = 20 ,
71105 attributes_not_assessed = 5 ,
72106 attributes_total = 25 ,
107+ config = None ,
73108 duration_seconds = 1.5 ,
74109 )
75110
@@ -393,9 +428,7 @@ def test_load_config_sensitive_output_dir(self, tmp_path):
393428 config_file = tmp_path / "config.yaml"
394429 config_file .write_text ("output_dir: /etc/passwords" )
395430
396- with pytest .raises (
397- ValueError , match = "cannot be in sensitive system directory"
398- ):
431+ with pytest .raises (ValueError , match = "cannot be in sensitive system directory" ):
399432 load_config (config_file )
400433
401434 def test_load_config_invalid_report_theme (self , tmp_path ):
@@ -482,9 +515,7 @@ def test_generate_config_creates_file(self, runner):
482515 """Test generate-config creates config file."""
483516 with runner .isolated_filesystem ():
484517 # Create example config
485- Path (".agentready-config.example.yaml" ).write_text (
486- "weights:\n attr1: 1.0"
487- )
518+ Path (".agentready-config.example.yaml" ).write_text ("weights:\n attr1: 1.0" )
488519
489520 result = runner .invoke (generate_config , [])
490521
@@ -504,9 +535,7 @@ def test_generate_config_overwrite_prompt(self, runner):
504535 """Test generate-config prompts when file exists."""
505536 with runner .isolated_filesystem ():
506537 # Create both example and target
507- Path (".agentready-config.example.yaml" ).write_text (
508- "weights:\n attr1: 1.0"
509- )
538+ Path (".agentready-config.example.yaml" ).write_text ("weights:\n attr1: 1.0" )
510539 Path (".agentready-config.yaml" ).write_text ("existing: content" )
511540
512541 # Decline overwrite
@@ -520,9 +549,7 @@ def test_generate_config_overwrite_confirm(self, runner):
520549 """Test generate-config overwrites when confirmed."""
521550 with runner .isolated_filesystem ():
522551 # Create both example and target
523- Path (".agentready-config.example.yaml" ).write_text (
524- "weights:\n attr1: 2.0"
525- )
552+ Path (".agentready-config.example.yaml" ).write_text ("weights:\n attr1: 2.0" )
526553 Path (".agentready-config.yaml" ).write_text ("existing: content" )
527554
528555 # Confirm overwrite
@@ -598,9 +625,7 @@ def test_assess_large_repo_warning(self, runner, test_repo, mock_assessment):
598625 mock_scanner_class .return_value = mock_scanner
599626
600627 # Mock file count to be large
601- with patch (
602- "agentready.cli.main.safe_subprocess_run"
603- ) as mock_subprocess :
628+ with patch ("agentready.cli.main.safe_subprocess_run" ) as mock_subprocess :
604629 # Simulate large repo with 15000 files
605630 mock_subprocess .return_value = MagicMock (
606631 returncode = 0 , stdout = "\n " .join (["file.py" ] * 15000 )
@@ -624,7 +649,9 @@ def test_run_assessment_function(self, test_repo, mock_assessment):
624649 mock_scanner_class .return_value = mock_scanner
625650
626651 # Call run_assessment directly
627- run_assessment (str (test_repo ), verbose = False , output_dir = None , config_path = None )
652+ run_assessment (
653+ str (test_repo ), verbose = False , output_dir = None , config_path = None
654+ )
628655
629656 # Should have created reports
630657 assert (test_repo / ".agentready" ).exists ()
0 commit comments