Skip to content

🧪 Xircuits CLI Tests - #391

Merged
MFA-X-AI merged 8 commits into
masterfrom
fahreza/cli-tests
Apr 1, 2025
Merged

MFA-X-AI merged 8 commits into
masterfrom
fahreza/cli-tests

Conversation

@MFA-X-AI

Copy link
Copy Markdown
Member

Description

This PR implements comprehensive testing for the Xircuits CLI, covering all major commands and features including initialization, compilation, execution, library management, and Jupyter integration. The test suite ensures reliability of the CLI interface across various usage scenarios.

The test suite was designed with isolation in mind - each test operates in its own temporary directory to prevent interference between tests. The framework includes a run_command helper that handles process management, output verification, and cleanup.

The tests use a combination of direct CLI command invocation and output/file verification to ensure the commands behave as expected. Several edge cases are covered, including error handling, re-initialization, and behavior in uninitialized directories.

The GitHub Actions workflow validates these tests automatically on pull requests to ensure ongoing reliability of the CLI interface.

References

N/A

Pull Request Type

  • Xircuits Core (Jupyterlab Related changes)
  • Xircuits Canvas (Custom RD Related changes)
  • Xircuits Component Library
  • Xircuits Project Template
  • Testing Automation
  • Documentation
  • Others (Please Specify)

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Tests

This PR includes the following test cases for the Xircuits CLI:

1. Basic Command Tests

  1. test_01_help_command - Tests xircuits --h shows help content
  2. test_02_alternative_help_command - Tests xircuits --help shows help content
  3. test_03_init_command - Tests xircuits init creates .xircuits and xai_components directories

2. Core Functionality Tests
4. test_04_compile_command - Tests xircuits compile file.xircuits properly generates Python code
5. test_05_run_command - Tests xircuits run file.xircuits compiles and executes workflows
6. test_06_list_libraries_command - Tests xircuits list shows available component libraries
7. test_07_install_library_command - Tests xircuits install library_name installs libraries
8. test_08_working_directory_detection - Tests CLI correctly detects Xircuits working directory
9. test_09_compile_with_custom_output - Tests xircuits compile file.xircuits output.py uses custom output
10. test_10_error_handling_invalid_command - Tests xircuits invalid_command gives appropriate error

3. Library Management Tests
11. test_11_install_invalid_library - Tests xircuits install non_existing_library gives appropriate error
12. test_12_fetch_only_valid_library - Tests xircuits fetch-only library_name fetches without installing
13. test_13_install_already_installed_library - Tests reinstalling existing libraries

4. Advanced Compilation Tests
14. test_14_compile_invalid_xircuits - Tests error handling for compiling invalid Xircuits files
15. test_15_compile_with_python_paths_file - Tests --python-paths-file option for component paths
16. test_16_run_existing_py_file - Tests xircuits run file.py directly runs Python files
17. test_17_run_with_custom_output - Tests xircuits run file.xircuits output.py uses custom output
18. test_18_run_invalid_xircuits - Tests xircuits run invalid.xircuits handles errors appropriately
19. test_19_run_with_python_paths_file - Tests run command with component path specification
20. test_20_run_with_custom_arguments - Tests xircuits run file.xircuits -- --arg=value passes arguments

5. Jupyterlab Integration Tests
21. test_21_no_arguments_starts_jupyter_lab - Tests xircuits with no args starts Jupyter Lab
22. test_22_start_command - Tests xircuits start launches JupyterLab
23. test_23_start_with_extra_arguments - Tests xircuits start --port=8899 passes args to Jupyter

6. Environment Management Tests
24. test_24_auto_initialization - Tests initialization via XIRCUITS_INIT environment variable
25. test_25_reinit_in_already_initialized_directory - Tests reinitialization in existing directories
26. test_26_start_in_non_initialized_directory - Tests start behavior in non-initialized directories
27. test_27_xircuits_missing_xai_components - Tests behavior with missing xai_components

7. Advanced Workflow Tests
28. test_28_run_non_recursive_mode_with_install - Tests --non-recursive flag for run command
29. test_29_compile_non_recursive_mode_with_install - Tests --non-recursive flag for compile command

To verify tests:

  1. Clone this PR branch
  2. Run tests with: pytest -xvs test_xircuits_cli.py
  3. Verify that all tests pass
  4. Check GitHub Actions to ensure tests pass in the CI environment

Tested on? Specify Version.

  • Linux
  • Windows
  • Mac
  • Others

Notes

Thanks @rabea-al for finishing up the tests!

@github-actions

Copy link
Copy Markdown

Binder 👈 Launch a binder notebook on branch XpressAI/xircuits/fahreza/cli-tests

@MFA-X-AI
MFA-X-AI merged commit b91760e into master Apr 1, 2025
@MFA-X-AI
MFA-X-AI deleted the fahreza/cli-tests branch April 1, 2025 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants