-
Notifications
You must be signed in to change notification settings - Fork 0
Tt 98 toogles backend #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
89f6c51
TT-98 feat: add feature flags
PaulRC-ioet 71e7ed4
TT-98 fix: refactor feature toggle manager
PaulRC-ioet 384f37c
TT-98 feat: Add test to feature toggle manager file
PaulRC-ioet 6cde781
TT-98 fix: refactor code in feature toggles file
PaulRC-ioet f3e7109
TT-98 fix: upgrate version of azure core
PaulRC-ioet 036c8db
TT-98 fix: refactor comments made by Roberto
PaulRC-ioet 14b377d
TT-98 fix: remove import in time_entries_namespaces
PaulRC-ioet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
TT-98 feat: Add test to feature toggle manager file
- Loading branch information
commit 384f37c80b6c9f5f92ccda50dce51250813f99ac
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
tests/commons/feature_toggles/feature_toggles_manager_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| from commons.feature_toggles.feature_toggle_manager import FeatureToggleManager | ||
| from unittest.mock import Mock, patch | ||
| from pytest import mark | ||
|
|
||
|
|
||
| def mock_payload(enabled, user): | ||
Angeluz-07 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return { | ||
| "id": "test-feature-toggle", | ||
| "description": "Feature Toggle test Backend", | ||
| "enabled": enabled, | ||
| "conditions": { | ||
| "client_filters": [ | ||
| { | ||
| "name": "Microsoft.Targeting", | ||
| "parameters": { | ||
| "Audience": { | ||
| "Users": [user], | ||
| "Groups": [], | ||
| "DefaultRolloutPercentage": 50, | ||
| } | ||
| }, | ||
| } | ||
| ] | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| @patch( | ||
| 'azure.appconfiguration.AzureAppConfigurationClient.from_connection_string', | ||
| new_callable=Mock, | ||
| ) | ||
| @patch( | ||
| 'commons.feature_toggles.feature_toggle_manager.FeatureToggleManager.get_data_configuration', | ||
| new_callable=Mock, | ||
| ) | ||
| @patch('commons.feature_toggles.feature_toggle_manager.current_user_email') | ||
| @mark.parametrize( | ||
| 'user_email_enabled,currrent_user_email,is_toggle_enabled,expected_result', | ||
| [ | ||
| ('[email protected]', '[email protected]', True, True), | ||
| ('[email protected]', '[email protected]', False, False), | ||
| ('[email protected]', '[email protected]', True, False), | ||
| ('[email protected]', '[email protected]', False, False), | ||
| ], | ||
| ) | ||
| def test_if_is_toggle_enabled_for_user( | ||
| current_user_email_mock, | ||
| get_data_configuration_mock, | ||
| from_connection_string_mock, | ||
| user_email_enabled, | ||
| currrent_user_email, | ||
| is_toggle_enabled, | ||
| expected_result, | ||
| ): | ||
| current_user_email_mock.return_value = currrent_user_email | ||
| feature_toggle_manager = FeatureToggleManager("test-feature-toggle") | ||
| feature_toggle_manager.get_data_configuration.return_value = mock_payload( | ||
| is_toggle_enabled, user_email_enabled | ||
| ) | ||
|
|
||
| assert ( | ||
| feature_toggle_manager.is_toggle_enabled_for_user() == expected_result | ||
| ) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.