Skip to content

feat(python): add unit tests and remove hardcoded credentials#49

Open
57388sp wants to merge 2 commits into
mainfrom
feat/python-cleanup-remove-credentials
Open

feat(python): add unit tests and remove hardcoded credentials#49
57388sp wants to merge 2 commits into
mainfrom
feat/python-cleanup-remove-credentials

Conversation

@57388sp
Copy link
Copy Markdown
Collaborator

@57388sp 57388sp commented May 22, 2026

Summary
Add a comprehensive unit test suite for all Python scripts and remove all
hardcoded credentials and environment-specific values.

Changes

Unit tests (new)

  • Unit_tests - 142 tests covering all 9 scripts + OntapClient
  • pytest.ini - test configuration
  • requirements-dev.txt - dev/test dependencies

Python scripts

  • Cleared from all INPUTS/ENV blocks: IP addresses, passwords, SVM names,
    volume names, aggregate names - all must now be supplied via environment variables
  • Refactored ontap_client.py: _DEFAULT_TIMEOUT=90, added poll_job(),
    wait_snapmirrored(), load_env_file(), update_auth(), __all__
  • Reduced cyclomatic complexity - all functions A/B grade (radon)
  • Fixed non-ASCII characters in comments
  • Added type hints and docstrings to all public functions

Quality gates

  • ruff check python/ Unit_tests/ - 0 warnings
  • pytest Unit_tests/ -q - 142 passed

Security

  • No credentials, IPs, or environment-specific values remain in source files
  • All sensitive inputs must be provided via os.environ or the INPUTS/ENV
    dict at runtime

- Clear all hardcoded IPs, passwords, SVM/volume/aggregate names from
  INPUTS/ENV blocks in all 9 Python scripts; values must now be supplied
  via environment variables or the INPUTS dict at runtime
- Add Unit_tests/ suite: 142 tests covering all 9 scripts + OntapClient
- Add pytest.ini and requirements-dev.txt for test tooling
- Refactor ontap_client: _DEFAULT_TIMEOUT=90, poll_job, wait_snapmirrored,
  load_env_file, update_auth, __all__
- Reduce cyclomatic complexity across all scripts (all functions A/B grade)
- Fix non-ASCII characters in comments (U+2026, U+2192 replaced)
- Add type hints and docstrings to all public functions
- ruff: 0 warnings; pytest: 142 passed
@57388sp 57388sp requested a review from hvinn as a code owner May 22, 2026 10:30
@github-actions github-actions Bot added needs-test-report python Pull requests that update python code docs and removed needs-test-report labels May 22, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

Test Report

Environment: N/A - this PR does not add or modify a runnable example.
It adds unit tests and removes hardcoded credentials from existing scripts.

The changes in this PR are:

  1. Removal of hardcoded credentials/IPs from INPUTS/ENV blocks (no
    behaviour change - scripts work identically, values come from env vars).
  2. Addition of Unit_tests - these are mock-based unit tests that run
    without a cluster.

Unit test run (first run):

python -m pytest Unit_tests/ -q
............................................................... [ 40%]
............................................................... [ 80%]
................................................................[100%]
142 passed in 0.30s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs needs-test-report python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant