From 1b737522b4891d778edd1b0d322b5daa73090c2e Mon Sep 17 00:00:00 2001 From: Sahil Lenka Date: Sun, 15 Feb 2026 05:39:00 +0530 Subject: [PATCH] Add test coverage for inspect command The inspect command had no tests, which left a gap in our test coverage. Added 4 new tests covering: - Basic workflow inspection - JSON output format - Missing file error handling - Detection of missing source files All tests pass. --- tests/test_cli.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index b1853b49..f852d5c1 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -150,6 +150,47 @@ def test_run_command_existing_output(self): '--output', 'output' ]) self.assertIn('already exists', result.output.lower()) + + def test_inspect_command_basic(self): + with self.runner.isolated_filesystem(temp_dir=self.temp_dir): + result = self.runner.invoke(cli, ['init', 'test-project']) + self.assertEqual(result.exit_code, 0) + + result = self.runner.invoke(cli, ['inspect', 'test-project/workflow.graphml']) + self.assertEqual(result.exit_code, 0) + self.assertIn('Workflow Overview', result.output) + self.assertIn('Nodes:', result.output) + self.assertIn('Edges:', result.output) + + def test_inspect_missing_file(self): + result = self.runner.invoke(cli, ['inspect', 'nonexistent.graphml']) + self.assertNotEqual(result.exit_code, 0) + + def test_inspect_json_output(self): + with self.runner.isolated_filesystem(temp_dir=self.temp_dir): + result = self.runner.invoke(cli, ['init', 'test-project']) + self.assertEqual(result.exit_code, 0) + + result = self.runner.invoke(cli, ['inspect', 'test-project/workflow.graphml', '--json']) + self.assertEqual(result.exit_code, 0) + + import json + output_data = json.loads(result.output) + self.assertIn('workflow', output_data) + self.assertIn('nodes', output_data) + self.assertIn('edges', output_data) + self.assertEqual(output_data['workflow'], 'workflow.graphml') + + def test_inspect_missing_source_file(self): + with self.runner.isolated_filesystem(temp_dir=self.temp_dir): + result = self.runner.invoke(cli, ['init', 'test-project']) + self.assertEqual(result.exit_code, 0) + + Path('test-project/src/script.py').unlink() + + result = self.runner.invoke(cli, ['inspect', 'test-project/workflow.graphml', '--source', 'src']) + self.assertEqual(result.exit_code, 0) + self.assertIn('Missing files', result.output) if __name__ == '__main__': unittest.main()