-
Notifications
You must be signed in to change notification settings - Fork 40
fix: Create shared test fixtures and fix Assessment schema issues (#109) #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,6 @@ | ||
| { | ||
| "generated_at": "2025-11-21T14:17:47.941871", | ||
| "skill_count": 2, | ||
| "generated_at": "2025-11-23T00:18:53.479358", | ||
| "skill_count": 0, | ||
| "min_confidence": 70, | ||
| "discovered_skills": [ | ||
| { | ||
| "skill_id": "setup-claude-md", | ||
| "name": "Setup CLAUDE.md Configuration", | ||
| "description": "Create comprehensive CLAUDE.md files with tech stack, standard commands, repository structure, and boundaries to optimize repositories for AI-assisted development", | ||
| "confidence": 100.0, | ||
| "source_attribute_id": "claude_md_file", | ||
| "reusability_score": 100.0, | ||
| "impact_score": 50.0, | ||
| "pattern_summary": "Project-specific configuration for Claude Code", | ||
| "code_examples": [ | ||
| "CLAUDE.md found at /Users/jeder/repos/agentready/CLAUDE.md" | ||
| ], | ||
| "citations": [] | ||
| }, | ||
| { | ||
| "skill_id": "implement-type-annotations", | ||
| "name": "Implement Type Annotations", | ||
| "description": "Add comprehensive type hints to Python/TypeScript code to improve IDE support, catch errors early, and enable better AI code understanding", | ||
| "confidence": 100.0, | ||
| "source_attribute_id": "type_annotations", | ||
| "reusability_score": 100.0, | ||
| "impact_score": 50.0, | ||
| "pattern_summary": "Type hints in function signatures", | ||
| "code_examples": [ | ||
| "Typed functions: 180/186", | ||
| "Coverage: 96.8%" | ||
| ], | ||
| "citations": [] | ||
| } | ||
| ] | ||
| "discovered_skills": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Shared test fixtures for AgentReady tests.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| """Shared test fixtures for creating valid Assessment JSON data. | ||
|
|
||
| This module provides factory functions for generating valid Assessment and Finding | ||
| JSON structures that match the current schema (v1.0.0). | ||
|
|
||
| The fixtures ensure consistency across tests and prevent schema breakage. | ||
| """ | ||
|
|
||
|
|
||
| def create_test_assessment_json( | ||
| overall_score=85.0, | ||
| num_findings=2, | ||
| repo_path="/tmp/test", | ||
| repo_name="test-repo", | ||
| certification_level=None, | ||
| ): | ||
| """Create valid Assessment JSON matching current schema. | ||
|
|
||
| Args: | ||
| overall_score: Score between 0-100 | ||
| num_findings: Number of findings to include (must match attributes_total) | ||
| repo_path: Repository path | ||
| repo_name: Repository name | ||
| certification_level: Override certification level (auto-calculated if None) | ||
|
|
||
| Returns: | ||
| dict: Valid Assessment JSON that can be serialized and loaded | ||
| """ | ||
| if certification_level is None: | ||
| # Auto-calculate certification level | ||
| if overall_score >= 90: | ||
| certification_level = "Platinum" | ||
| elif overall_score >= 75: | ||
| certification_level = "Gold" | ||
| elif overall_score >= 60: | ||
| certification_level = "Silver" | ||
| elif overall_score >= 40: | ||
| certification_level = "Bronze" | ||
| else: | ||
| certification_level = "Needs Improvement" | ||
|
|
||
| findings = [] | ||
| for i in range(num_findings): | ||
| status = "pass" if overall_score >= 60 else "fail" | ||
| score = overall_score if status == "pass" else max(0, overall_score - 10) | ||
| findings.append( | ||
| create_test_finding_json( | ||
| attribute_id=f"test_attr_{i}", | ||
| attribute_name=f"Test Attribute {i}", | ||
| status=status, | ||
| score=score, | ||
| ) | ||
| ) | ||
|
|
||
| return { | ||
| "schema_version": "1.0.0", | ||
| "timestamp": "2025-11-22T06:00:00", | ||
| "repository": { | ||
| "name": repo_name, | ||
| "path": repo_path, | ||
| "url": None, | ||
| "branch": "main", | ||
| "commit_hash": "abc123", | ||
| "languages": {"Python": 100}, | ||
| "total_files": 10, | ||
| "total_lines": 500, | ||
| }, | ||
| "overall_score": overall_score, | ||
| "certification_level": certification_level, | ||
| "attributes_assessed": num_findings, | ||
| "attributes_not_assessed": 0, | ||
| "attributes_total": num_findings, | ||
| "findings": findings, | ||
| "config": None, # CRITICAL: Must be present in current schema | ||
| "duration_seconds": 1.5, | ||
| "discovered_skills": [], # Optional but good to include | ||
| } | ||
|
|
||
|
|
||
| def create_test_finding_json( | ||
| attribute_id="test_attr", | ||
| attribute_name="Test Attribute", | ||
| status="pass", | ||
| score=90.0, | ||
| category="Documentation", | ||
| tier=1, | ||
| ): | ||
| """Create valid Finding JSON. | ||
|
|
||
| Args: | ||
| attribute_id: Unique attribute identifier | ||
| attribute_name: Human-readable attribute name | ||
| status: pass, fail, skipped, error, or not_applicable | ||
| score: Score 0-100 (or None for non-pass/fail statuses) | ||
| category: Attribute category | ||
| tier: Attribute tier (1-4) | ||
|
|
||
| Returns: | ||
| dict: Valid Finding JSON | ||
| """ | ||
| return { | ||
| "attribute": { | ||
| "id": attribute_id, | ||
| "name": attribute_name, | ||
| "category": category, | ||
| "tier": tier, | ||
| "description": f"Test description for {attribute_name}", | ||
| "criteria": "Test criteria", | ||
| "default_weight": 1.0, | ||
| }, | ||
| "status": status, | ||
| "score": score if status in ("pass", "fail") else None, | ||
| "measured_value": "present" if status == "pass" else "missing", | ||
| "threshold": "present", | ||
| "evidence": [f"Test evidence for {attribute_name}"], | ||
| "error_message": None if status != "error" else "Test error", | ||
| } | ||
|
|
||
|
|
||
| def create_test_repository_json(path="/tmp/test", name="test-repo", languages=None): | ||
| """Create valid Repository JSON. | ||
|
|
||
| Args: | ||
| path: Repository path | ||
| name: Repository name | ||
| languages: Language breakdown dict (default: {"Python": 100}) | ||
|
|
||
| Returns: | ||
| dict: Valid Repository JSON | ||
| """ | ||
| if languages is None: | ||
| languages = {"Python": 100} | ||
|
|
||
| return { | ||
| "name": name, | ||
| "path": path, | ||
| "url": None, | ||
| "branch": "main", | ||
| "commit_hash": "abc123", | ||
| "languages": languages, | ||
| "total_files": 10, | ||
| "total_lines": 500, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The align command now skips constructing a
Repositoryand only instantiatesScannerand assessors (lines 79-83), but the subsequent call tofixer_service.generate_fix_plan(assessment, repo, attribute_list)still passesrepo, which is never defined anymore. After a scan completes, runningagentready alignwill throw aNameErrorinstead of producing a fix plan for any repository. A repository object (e.g., from the scanner’s assessment) needs to be created or reused before generating the plan.Useful? React with 👍 / 👎.