-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Summary
Several test methods contain parameter/config validation logic that should be in fixtures instead. Per CLAUDE.md "Validate at Source" principle, validation should happen in fixtures where values originate, not in test methods.
Problem / Motivation
Test methods should focus on testing behavior, not validating configuration. When validation happens in test methods:
- Tests become harder to maintain
- Validation logic is duplicated across tests
- Skip/fail conditions are scattered instead of centralized
- It violates the "Validate at Source" pattern
Requirements
Violations Found
| Location | Pattern | What's Validated |
|---|---|---|
test_copyoffload_migration.py:209-210 |
pytest.skip() in test |
vSphere provider type |
test_copyoffload_migration.py:851-852 |
pytest.fail() in test |
rdm_lun_uuid config |
test_copyoffload_migration.py:1002-1020 |
pytest.fail() in test |
storage_vendor_product, datastore_id, secondary_datastore_id |
test_copyoffload_migration.py:1785-1796 |
pytest.fail() in test |
storage_vendor_product, datastore_id |
test_mtv_warm_migration.py:18-27 |
Module-level skipif | Provider type for warm migration |
Issues Identified
- Redundant validation:
copyoffload_configfixture already validatesstorage_vendor_productanddatastore_id, but tests check again - Missing fixture validations:
rdm_lun_uuidandsecondary_datastore_idshould have dedicated fixtures pytest.skip()andpytest.fail()inside test methods violate the "Validate at Source" pattern
Deliverables
- Remove redundant validation from test methods (items 3, 4, 5 in table above)
- Create
rdm_lun_uuidvalidation fixture for RDM tests - Create
secondary_datastore_idvalidation fixture for multi-datastore tests - Use
@pytest.mark.skipifat class level instead ofpytest.skip()in test methods - Review module-level skipif pattern in warm migration tests
- Update CLAUDE.md (if codebase structure changes)
Notes
- The
copyoffload_configfixture intests/conftest.pyalready validates some fields - avoid duplicating this validation - New fixtures should follow the existing pattern: validate at fixture level, raise
ValueErrorwith clear message if invalid - Use
@pytest.mark.skipifwith helper functions for conditional test skipping
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels