Skip to content

feat: added support for conditional strategy mocking#51

Merged
petruki merged 1 commit intomasterfrom
feat_mock
Apr 28, 2026
Merged

feat: added support for conditional strategy mocking#51
petruki merged 1 commit intomasterfrom
feat_mock

Conversation

@petruki
Copy link
Copy Markdown
Member

@petruki petruki commented Apr 28, 2026

This pull request introduces significant enhancements to the mocking and bypassing capabilities of the Switcher SDK, allowing for more flexible and testable feature flag behaviors. The main changes include the implementation of conditional mocking based on input criteria, support for attaching metadata to mocked results, and comprehensive tests to ensure the new features work as expected.

Mocking & Bypasser Enhancements

  • Added conditional mocking methods (when, with_metadata, true, false) to the Key class in switcher_client/lib/bypasser/key.py, enabling feature flags to be forced on/off based on specific strategies and input values, with optional metadata attached to responses.
  • Updated the Switcher.is_on_with_details method to check for bypassed keys and return the mocked result with details, integrating the new bypassing logic into the main evaluation flow.

Public API & Documentation

  • Exported StrategiesType in switcher_client/__init__.py to make strategy types available for mocking criteria in user code.
  • Updated the README to document the new mocking features, including conditional mocking and metadata support, with code examples.

Testing

  • Added comprehensive tests in tests/test_switcher_stub.py to verify basic and advanced mocking scenarios, including conditional criteria, metadata, and multiple strategy values.
  • Imported StrategiesType in test files to support new mocking criteria in tests.

These changes greatly improve the SDK's testability and flexibility for feature flag evaluation in development and CI environments.

@petruki petruki added this to the v1.0.0 milestone Apr 28, 2026
@petruki petruki self-assigned this Apr 28, 2026
@petruki petruki added the enhancement New feature or request label Apr 28, 2026
@sonarqubecloud
Copy link
Copy Markdown

@petruki petruki merged commit 4179692 into master Apr 28, 2026
15 checks passed
@petruki petruki deleted the feat_mock branch April 28, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant