Skip to content

Refactor CLI tests in tests/test_main.py to use default_load_config_kwargs #366

@szy196

Description

@szy196

Background & Motivation

The load_config function in wptgen/config.py has been significantly refactored, adding numerous optional parameters to support new features (resume-from, state-dir, lightweight/reasoning models, etc.). Currently, many CLI tests in tests/test_main.py (like test_audit_success and test_chromestatus_command) perform partial assertions on the load_config call's keyword arguments.

While this approach works, it is less robust than performing a full comparison against a set of expected default values. A more maintainable pattern is to use a central fixture, such as default_load_config_kwargs, to provide a baseline of expected arguments and then override only the ones relevant to a specific test case.

Proposed Changes

  • Update all CLI command tests in tests/test_main.py (e.g., test_generate_success, test_audit_success, test_chromestatus_command, test_list_models_command, etc.) to use mock_load_config.assert_called_once_with(**expected_kwargs).
  • Ensure expected_kwargs is derived from a default_load_config_kwargs fixture to minimize boilerplate and improve consistency.
  • Standardize the way CLI flags are validated to ensure all parameters are correctly passed to the configuration layer.

Acceptance Criteria

  • test_audit_success uses assert_called_once_with with a full set of expected arguments.
  • test_chromestatus_command uses assert_called_once_with with a full set of expected arguments.
  • All other relevant tests in tests/test_main.py are refactored to use the same pattern.
  • All tests in tests/test_main.py pass after the refactor.

This issue description was drafted by Gemini

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions