fix: sync CLI flags across analyze/pdf/unified commands and fix workflow JSON config
Flag/option synchronization fixes: - analyze: add --dry-run, --api-key, and all workflow flags (--enhance-workflow, --enhance-stage, --var, --workflow-dry-run) via WORKFLOW_ARGUMENTS merge - pdf: add --api-key to PDF_ARGUMENTS; replace 5 hardcoded add_argument() calls in pdf_scraper.py:main() with add_pdf_arguments() to activate all defined args - unified: add --api-key and --enhance-level (global override) to UNIFIED_ARGUMENTS and standalone parser; wire enhance_level CLI override into run() per-source loop - codebase_scraper: fix --enhance-workflow to use action="append" (was type=str), enabling multiple workflow chaining instead of silently dropping all but last ConfigManager test isolation fix: - __init__ now reads self.CONFIG_DIR/CONFIG_FILE/PROGRESS_DIR class variables instead of calling _get_config_dir()/_get_progress_dir() directly, enabling monkeypatching in tests (fixes pre-existing test_add_and_retrieve_github_profile) Workflow JSON config support in unified_scraper: - Phase 5 now reads workflows/workflow_stages/workflow_vars from top-level JSON config and merges them with CLI args (CLI-first ordering); supports running workflows even when unified scraper is called without CLI args (args=None) Tests: 1,949 passed, 0 failed (added 18 new tests across 3 test files) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -181,5 +181,89 @@ class TestAnalyzePresetBehavior(unittest.TestCase):
|
||||
self.assertFalse(args.comprehensive)
|
||||
|
||||
|
||||
class TestAnalyzeWorkflowFlags(unittest.TestCase):
|
||||
"""Test workflow and parity flags added to the analyze subcommand."""
|
||||
|
||||
def setUp(self):
|
||||
"""Create parser for testing."""
|
||||
self.parser = create_parser()
|
||||
|
||||
def test_enhance_workflow_accepted_as_list(self):
|
||||
"""Test --enhance-workflow is accepted and stored as a list."""
|
||||
args = self.parser.parse_args(
|
||||
["analyze", "--directory", ".", "--enhance-workflow", "security-focus"]
|
||||
)
|
||||
self.assertEqual(args.enhance_workflow, ["security-focus"])
|
||||
|
||||
def test_enhance_workflow_chained_twice(self):
|
||||
"""Test --enhance-workflow can be chained to produce a two-item list."""
|
||||
args = self.parser.parse_args(
|
||||
[
|
||||
"analyze",
|
||||
"--directory",
|
||||
".",
|
||||
"--enhance-workflow",
|
||||
"security-focus",
|
||||
"--enhance-workflow",
|
||||
"minimal",
|
||||
]
|
||||
)
|
||||
self.assertEqual(args.enhance_workflow, ["security-focus", "minimal"])
|
||||
|
||||
def test_enhance_stage_accepted_as_list(self):
|
||||
"""Test --enhance-stage is accepted with action=append."""
|
||||
args = self.parser.parse_args(
|
||||
["analyze", "--directory", ".", "--enhance-stage", "sec:Analyze security"]
|
||||
)
|
||||
self.assertEqual(args.enhance_stage, ["sec:Analyze security"])
|
||||
|
||||
def test_var_accepted_as_list(self):
|
||||
"""Test --var is accepted with action=append (dest is 'var')."""
|
||||
args = self.parser.parse_args(
|
||||
["analyze", "--directory", ".", "--var", "focus=performance"]
|
||||
)
|
||||
self.assertEqual(args.var, ["focus=performance"])
|
||||
|
||||
def test_workflow_dry_run_flag(self):
|
||||
"""Test --workflow-dry-run sets the flag."""
|
||||
args = self.parser.parse_args(
|
||||
["analyze", "--directory", ".", "--workflow-dry-run"]
|
||||
)
|
||||
self.assertTrue(args.workflow_dry_run)
|
||||
|
||||
def test_api_key_stored_correctly(self):
|
||||
"""Test --api-key is stored in args."""
|
||||
args = self.parser.parse_args(
|
||||
["analyze", "--directory", ".", "--api-key", "sk-ant-test"]
|
||||
)
|
||||
self.assertEqual(args.api_key, "sk-ant-test")
|
||||
|
||||
def test_dry_run_stored_correctly(self):
|
||||
"""Test --dry-run is stored in args."""
|
||||
args = self.parser.parse_args(["analyze", "--directory", ".", "--dry-run"])
|
||||
self.assertTrue(args.dry_run)
|
||||
|
||||
def test_workflow_flags_combined(self):
|
||||
"""Test workflow flags can be combined with other analyze flags."""
|
||||
args = self.parser.parse_args(
|
||||
[
|
||||
"analyze",
|
||||
"--directory",
|
||||
".",
|
||||
"--enhance-workflow",
|
||||
"security-focus",
|
||||
"--api-key",
|
||||
"sk-ant-test",
|
||||
"--dry-run",
|
||||
"--enhance-level",
|
||||
"1",
|
||||
]
|
||||
)
|
||||
self.assertEqual(args.enhance_workflow, ["security-focus"])
|
||||
self.assertEqual(args.api_key, "sk-ant-test")
|
||||
self.assertTrue(args.dry_run)
|
||||
self.assertEqual(args.enhance_level, 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user