switcher-client 1.2.0__tar.gz → 1.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {switcher_client-1.2.0/switcher_client.egg-info → switcher_client-1.2.2}/PKG-INFO +6 -6
- {switcher_client-1.2.0 → switcher_client-1.2.2}/README.md +3 -3
- {switcher_client-1.2.0 → switcher_client-1.2.2}/pyproject.toml +2 -2
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/bypasser/bypasser.py +6 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/switcher_data.py +2 -2
- switcher_client-1.2.2/switcher_client/version.py +1 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2/switcher_client.egg-info}/PKG-INFO +6 -6
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_client_check_switchers.py +3 -3
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_client_context.py +3 -1
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_switcher_integration.py +11 -6
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_switcher_remote.py +17 -15
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_switcher_stub.py +15 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_switcher_stub_decorator.py +1 -1
- switcher_client-1.2.0/switcher_client/version.py +0 -1
- {switcher_client-1.2.0 → switcher_client-1.2.2}/LICENSE +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/setup.cfg +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/__init__.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/client.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/errors/__init__.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/__init__.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/bypasser/__init__.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/bypasser/key.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/compat.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/globals/__init__.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/globals/global_auth.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/globals/global_context.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/globals/global_retry.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/globals/global_snapshot.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/remote.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/remote_auth.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/resolver.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/snapshot.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/snapshot_auto_updater.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/snapshot_loader.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/snapshot_watcher.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/types.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/__init__.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/date_moment.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/execution_logger.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/ipcidr.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/payload_reader.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/timed_match/__init__.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/timed_match/timed_match.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/timed_match/worker.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/switcher.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/testing.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client.egg-info/SOURCES.txt +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client.egg-info/dependency_links.txt +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client.egg-info/requires.txt +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client.egg-info/top_level.txt +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_client_load_snapshot_file.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_client_load_snapshot_remote.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_client_watch_snapshot.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_switcher_local.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_switcher_logger.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_switcher_silent_mode.py +0 -0
- {switcher_client-1.2.0 → switcher_client-1.2.2}/tests/test_switcher_throttle.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: switcher-client
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Switcher Client SDK for Python
|
|
5
5
|
Author: Roger Floriano (petruki)
|
|
6
6
|
Author-email: switcher.project@gmail.com
|
|
@@ -13,16 +13,16 @@ Classifier: Development Status :: 5 - Production/Stable
|
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
14
14
|
Classifier: Programming Language :: Python
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
22
22
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
23
23
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
24
24
|
Classifier: Operating System :: OS Independent
|
|
25
|
-
Requires-Python: >=3.
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
License-File: LICENSE
|
|
28
28
|
Requires-Dist: httpx[http2]>=0.28.1
|
|
@@ -43,7 +43,7 @@ A Python SDK for Switcher API
|
|
|
43
43
|

|
|
44
44
|
[](https://pypi.org/project/switcher-client/)
|
|
45
45
|
[](https://anaconda.org/switcherapi/switcher-client)
|
|
46
|
-
[](https://www.python.org/downloads/)
|
|
47
47
|
[](https://opensource.org/licenses/MIT)
|
|
48
48
|
[](https://switcher-hq.slack.com/)
|
|
49
49
|
|
|
@@ -141,7 +141,7 @@ conda install switcherapi::switcher-client
|
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
### System Requirements
|
|
144
|
-
- **Python**: 3.
|
|
144
|
+
- **Python**: 3.10+ (supports 3.10, 3.11, 3.12, 3.13, 3.14, 3.15)
|
|
145
145
|
- **Operating System**: Cross-platform (Windows, macOS, Linux)
|
|
146
146
|
|
|
147
147
|
## Configuration
|
|
@@ -537,7 +537,7 @@ We welcome contributions to the Switcher Client SDK for Python! If you have sugg
|
|
|
537
537
|
Thank you for helping us improve the Switcher Client SDK!
|
|
538
538
|
|
|
539
539
|
### Requirements
|
|
540
|
-
- Python 3.
|
|
540
|
+
- Python 3.10 or higher
|
|
541
541
|
- Virtualenv - `pip install virtualenv`
|
|
542
542
|
- Create a virtual environment - `python3 -m venv .venv`
|
|
543
543
|
- Install Pipenv - `pip install pipenv`
|
|
@@ -12,7 +12,7 @@ A Python SDK for Switcher API
|
|
|
12
12
|

|
|
13
13
|
[](https://pypi.org/project/switcher-client/)
|
|
14
14
|
[](https://anaconda.org/switcherapi/switcher-client)
|
|
15
|
-
[](https://www.python.org/downloads/)
|
|
16
16
|
[](https://opensource.org/licenses/MIT)
|
|
17
17
|
[](https://switcher-hq.slack.com/)
|
|
18
18
|
|
|
@@ -110,7 +110,7 @@ conda install switcherapi::switcher-client
|
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
### System Requirements
|
|
113
|
-
- **Python**: 3.
|
|
113
|
+
- **Python**: 3.10+ (supports 3.10, 3.11, 3.12, 3.13, 3.14, 3.15)
|
|
114
114
|
- **Operating System**: Cross-platform (Windows, macOS, Linux)
|
|
115
115
|
|
|
116
116
|
## Configuration
|
|
@@ -506,7 +506,7 @@ We welcome contributions to the Switcher Client SDK for Python! If you have sugg
|
|
|
506
506
|
Thank you for helping us improve the Switcher Client SDK!
|
|
507
507
|
|
|
508
508
|
### Requirements
|
|
509
|
-
- Python 3.
|
|
509
|
+
- Python 3.10 or higher
|
|
510
510
|
- Virtualenv - `pip install virtualenv`
|
|
511
511
|
- Create a virtual environment - `python3 -m venv .venv`
|
|
512
512
|
- Install Pipenv - `pip install pipenv`
|
|
@@ -16,18 +16,18 @@ authors = [
|
|
|
16
16
|
]
|
|
17
17
|
license = "MIT"
|
|
18
18
|
license-files = ["LICENSE"]
|
|
19
|
-
requires-python = ">=3.
|
|
19
|
+
requires-python = ">=3.10"
|
|
20
20
|
classifiers = [
|
|
21
21
|
"Development Status :: 5 - Production/Stable",
|
|
22
22
|
"Intended Audience :: Developers",
|
|
23
23
|
"Programming Language :: Python",
|
|
24
24
|
"Programming Language :: Python :: 3",
|
|
25
|
-
"Programming Language :: Python :: 3.9",
|
|
26
25
|
"Programming Language :: Python :: 3.10",
|
|
27
26
|
"Programming Language :: Python :: 3.11",
|
|
28
27
|
"Programming Language :: Python :: 3.12",
|
|
29
28
|
"Programming Language :: Python :: 3.13",
|
|
30
29
|
"Programming Language :: Python :: 3.14",
|
|
30
|
+
"Programming Language :: Python :: 3.15",
|
|
31
31
|
"Programming Language :: Python :: 3 :: Only",
|
|
32
32
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
33
33
|
"Operating System :: OS Independent",
|
|
@@ -8,9 +8,12 @@ class Bypasser:
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
_bypassed_keys: ContextVar[dict[str, Key] | None] = ContextVar('bypassed_keys', default=None)
|
|
11
|
+
_bypass_enabled = False
|
|
11
12
|
|
|
12
13
|
@staticmethod
|
|
13
14
|
def assume(key: str) -> Key:
|
|
15
|
+
Bypasser._bypass_enabled = True
|
|
16
|
+
|
|
14
17
|
# Remove previous forced value if exists to avoid conflicts
|
|
15
18
|
new_key = Key(key)
|
|
16
19
|
bypassed_keys = dict(Bypasser._current_keys())
|
|
@@ -29,6 +32,9 @@ class Bypasser:
|
|
|
29
32
|
@staticmethod
|
|
30
33
|
def search_key(key: str) -> Key | None:
|
|
31
34
|
""" Search for key registered via 'assume' """
|
|
35
|
+
if not Bypasser._bypass_enabled:
|
|
36
|
+
return None
|
|
37
|
+
|
|
32
38
|
return Bypasser._current_keys().get(key)
|
|
33
39
|
|
|
34
40
|
@staticmethod
|
|
@@ -4,7 +4,7 @@ import json
|
|
|
4
4
|
from dataclasses import dataclass
|
|
5
5
|
from datetime import datetime
|
|
6
6
|
from abc import ABCMeta
|
|
7
|
-
from typing import Optional
|
|
7
|
+
from typing import Optional
|
|
8
8
|
|
|
9
9
|
from switcher_client.lib.compat import Self
|
|
10
10
|
from switcher_client.lib.utils import get
|
|
@@ -48,7 +48,7 @@ class SwitcherData(metaclass=ABCMeta):
|
|
|
48
48
|
""" Adds REGEX_VALIDATION input for strategy validation """
|
|
49
49
|
return self.check(StrategiesType.REGEX.value, input)
|
|
50
50
|
|
|
51
|
-
def check_payload(self, input:
|
|
51
|
+
def check_payload(self, input: str | dict) -> Self:
|
|
52
52
|
""" Adds PAYLOAD_VALIDATION input for strategy validation """
|
|
53
53
|
if isinstance(input, dict):
|
|
54
54
|
payload_str = json.dumps(input)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.2.2"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: switcher-client
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Switcher Client SDK for Python
|
|
5
5
|
Author: Roger Floriano (petruki)
|
|
6
6
|
Author-email: switcher.project@gmail.com
|
|
@@ -13,16 +13,16 @@ Classifier: Development Status :: 5 - Production/Stable
|
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
14
14
|
Classifier: Programming Language :: Python
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
22
22
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
23
23
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
24
24
|
Classifier: Operating System :: OS Independent
|
|
25
|
-
Requires-Python: >=3.
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
License-File: LICENSE
|
|
28
28
|
Requires-Dist: httpx[http2]>=0.28.1
|
|
@@ -43,7 +43,7 @@ A Python SDK for Switcher API
|
|
|
43
43
|

|
|
44
44
|
[](https://pypi.org/project/switcher-client/)
|
|
45
45
|
[](https://anaconda.org/switcherapi/switcher-client)
|
|
46
|
-
[](https://www.python.org/downloads/)
|
|
47
47
|
[](https://opensource.org/licenses/MIT)
|
|
48
48
|
[](https://switcher-hq.slack.com/)
|
|
49
49
|
|
|
@@ -141,7 +141,7 @@ conda install switcherapi::switcher-client
|
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
### System Requirements
|
|
144
|
-
- **Python**: 3.
|
|
144
|
+
- **Python**: 3.10+ (supports 3.10, 3.11, 3.12, 3.13, 3.14, 3.15)
|
|
145
145
|
- **Operating System**: Cross-platform (Windows, macOS, Linux)
|
|
146
146
|
|
|
147
147
|
## Configuration
|
|
@@ -537,7 +537,7 @@ We welcome contributions to the Switcher Client SDK for Python! If you have sugg
|
|
|
537
537
|
Thank you for helping us improve the Switcher Client SDK!
|
|
538
538
|
|
|
539
539
|
### Requirements
|
|
540
|
-
- Python 3.
|
|
540
|
+
- Python 3.10 or higher
|
|
541
541
|
- Virtualenv - `pip install virtualenv`
|
|
542
542
|
- Create a virtual environment - `python3 -m venv .venv`
|
|
543
543
|
- Install Pipenv - `pip install pipenv`
|
|
@@ -26,7 +26,7 @@ def test_check_remote_switchers_not_found(httpx_mock):
|
|
|
26
26
|
# test
|
|
27
27
|
try:
|
|
28
28
|
Client.check_switchers(['MY_SWITCHER', 'ANOTHER_SWITCHER'])
|
|
29
|
-
|
|
29
|
+
raise AssertionError('Expected RemoteSwitcherError to be raised')
|
|
30
30
|
except RemoteSwitcherError as e:
|
|
31
31
|
assert str(e) == 'MY_SWITCHER not found'
|
|
32
32
|
|
|
@@ -41,7 +41,7 @@ def test_check_remote_switchers_api_error(httpx_mock):
|
|
|
41
41
|
# test
|
|
42
42
|
try:
|
|
43
43
|
Client.check_switchers(['MY_SWITCHER', 'ANOTHER_SWITCHER'])
|
|
44
|
-
|
|
44
|
+
raise AssertionError('Expected RemoteError to be raised')
|
|
45
45
|
except Exception as e:
|
|
46
46
|
assert str(e) == '[check_switchers] failed with status: 500'
|
|
47
47
|
|
|
@@ -55,7 +55,7 @@ def test_chek_remote_switchers_auth_error(httpx_mock):
|
|
|
55
55
|
# test
|
|
56
56
|
try:
|
|
57
57
|
Client.check_switchers(['MY_SWITCHER', 'ANOTHER_SWITCHER'])
|
|
58
|
-
|
|
58
|
+
raise AssertionError('Expected RemoteError to be raised')
|
|
59
59
|
except Exception as e:
|
|
60
60
|
assert str(e) == 'Invalid API key'
|
|
61
61
|
|
|
@@ -25,9 +25,11 @@ def test_context_remote_validation():
|
|
|
25
25
|
domain='My Domain'
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
+
switcher = Client.get_switcher()
|
|
29
|
+
|
|
28
30
|
# test
|
|
29
31
|
with pytest.raises(ValueError) as excinfo:
|
|
30
|
-
|
|
32
|
+
switcher.validate() # used by is_on()
|
|
31
33
|
|
|
32
34
|
assert 'Missing or empty required fields (url, component, api_key)' in str(excinfo.value)
|
|
33
35
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
# Please, in order to run these tests, include a .env file in the root of the project with the following content:
|
|
2
|
+
# SWITCHER_URL=https://api.switcherapi.com
|
|
3
|
+
# SWITCHER_API_KEY=<your_api_key>
|
|
4
|
+
|
|
1
5
|
import os
|
|
2
6
|
from typing import Optional
|
|
3
7
|
|
|
@@ -8,13 +12,14 @@ from switcher_client.lib.globals.global_context import ContextOptions
|
|
|
8
12
|
from switcher_client.lib.globals.global_snapshot import LoadSnapshotOptions
|
|
9
13
|
|
|
10
14
|
load_dotenv()
|
|
11
|
-
|
|
15
|
+
SWITCHER_API_KEY = os.getenv('SWITCHER_API_KEY')
|
|
16
|
+
SWITCHER_URL = os.getenv('SWITCHER_URL')
|
|
12
17
|
WARN_SKIP = 'API key not found. Please set the SWITCHER_API_KEY environment variable.'
|
|
13
18
|
|
|
14
19
|
def test_is_on():
|
|
15
20
|
""" Should call the remote API with success """
|
|
16
21
|
|
|
17
|
-
if not
|
|
22
|
+
if not SWITCHER_API_KEY:
|
|
18
23
|
print(WARN_SKIP)
|
|
19
24
|
return
|
|
20
25
|
|
|
@@ -29,7 +34,7 @@ def test_is_on():
|
|
|
29
34
|
def test_load_snapshot():
|
|
30
35
|
""" Should load the snapshot from the remote API with success """
|
|
31
36
|
|
|
32
|
-
if not
|
|
37
|
+
if not SWITCHER_API_KEY:
|
|
33
38
|
print(WARN_SKIP)
|
|
34
39
|
return
|
|
35
40
|
|
|
@@ -47,7 +52,7 @@ def test_load_snapshot():
|
|
|
47
52
|
def test_check_switcher_availability():
|
|
48
53
|
""" Should check the switcher availability with success """
|
|
49
54
|
|
|
50
|
-
if not
|
|
55
|
+
if not SWITCHER_API_KEY:
|
|
51
56
|
print(WARN_SKIP)
|
|
52
57
|
return
|
|
53
58
|
|
|
@@ -64,8 +69,8 @@ def test_check_switcher_availability():
|
|
|
64
69
|
|
|
65
70
|
def given_context(options: Optional[ContextOptions] = None):
|
|
66
71
|
Client.build_context(
|
|
67
|
-
url=
|
|
68
|
-
api_key=
|
|
72
|
+
url=SWITCHER_URL,
|
|
73
|
+
api_key=SWITCHER_API_KEY,
|
|
69
74
|
domain='Switcher API',
|
|
70
75
|
component='switcher-client-python',
|
|
71
76
|
options=options
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import pytest
|
|
2
|
+
import sys
|
|
2
3
|
import time
|
|
3
4
|
import threading
|
|
4
5
|
import httpx
|
|
@@ -206,12 +207,12 @@ def test_remote_with_remote_required_request(httpx_mock):
|
|
|
206
207
|
# test
|
|
207
208
|
assert switcher.remote().is_on(key)
|
|
208
209
|
|
|
209
|
-
def test_remote_with_custom_cert(httpx_mock):
|
|
210
|
+
def test_remote_with_custom_cert(httpx_mock, monkeypatch):
|
|
210
211
|
""" Should call the remote API with success using a custom certificate """
|
|
211
212
|
|
|
212
213
|
# Reset Remote client to ensure fresh SSL context creation
|
|
213
214
|
from switcher_client.lib.remote import Remote
|
|
214
|
-
Remote
|
|
215
|
+
monkeypatch.setattr(Remote, '_client', None)
|
|
215
216
|
|
|
216
217
|
# given
|
|
217
218
|
given_auth(httpx_mock)
|
|
@@ -240,7 +241,7 @@ def test_remote_err_with_remote_reqquired_request_no_local():
|
|
|
240
241
|
|
|
241
242
|
# test
|
|
242
243
|
with pytest.raises(ValueError) as excinfo:
|
|
243
|
-
switcher.remote()
|
|
244
|
+
switcher.remote()
|
|
244
245
|
|
|
245
246
|
assert 'Local mode is not enabled' in str(excinfo.value)
|
|
246
247
|
|
|
@@ -306,7 +307,7 @@ def test_remote_err_check_criteria(httpx_mock):
|
|
|
306
307
|
|
|
307
308
|
assert '[check_criteria] failed with status: 500' in str(excinfo.value)
|
|
308
309
|
|
|
309
|
-
def test_remote_err_check_criteria_default_result(httpx_mock):
|
|
310
|
+
def test_remote_err_check_criteria_default_result(httpx_mock, monkeypatch):
|
|
310
311
|
""" Should return the default result when the check criteria fails """
|
|
311
312
|
|
|
312
313
|
# given
|
|
@@ -314,8 +315,9 @@ def test_remote_err_check_criteria_default_result(httpx_mock):
|
|
|
314
315
|
given_check_criteria(httpx_mock, show_details=True, status=500)
|
|
315
316
|
given_context()
|
|
316
317
|
|
|
317
|
-
|
|
318
|
-
|
|
318
|
+
this_module = sys.modules[__name__]
|
|
319
|
+
monkeypatch.setattr(this_module, 'async_error', None)
|
|
320
|
+
Client.subscribe_notify_error(lambda error: monkeypatch.setattr(this_module, 'async_error', str(error)))
|
|
319
321
|
switcher = Client.get_switcher()
|
|
320
322
|
|
|
321
323
|
# test
|
|
@@ -350,12 +352,12 @@ def test_remote_health_check_unavailable(httpx_mock):
|
|
|
350
352
|
# test
|
|
351
353
|
assert not Remote.check_api_health(Client._context)
|
|
352
354
|
|
|
353
|
-
def test_remote_client_rebuilds_when_timeout_changes(httpx_mock):
|
|
355
|
+
def test_remote_client_rebuilds_when_timeout_changes(httpx_mock, monkeypatch):
|
|
354
356
|
""" Should rebuild the shared remote client when timeout options change """
|
|
355
357
|
|
|
356
358
|
# given
|
|
357
|
-
Remote
|
|
358
|
-
Remote
|
|
359
|
+
monkeypatch.setattr(Remote, '_client', None)
|
|
360
|
+
monkeypatch.setattr(Remote, '_client_config', None)
|
|
359
361
|
given_auth(httpx_mock)
|
|
360
362
|
given_check_criteria(httpx_mock, response={'result': True}, match={'entry': []},
|
|
361
363
|
match_extensions={
|
|
@@ -401,12 +403,12 @@ def test_remote_client_rebuilds_when_timeout_changes(httpx_mock):
|
|
|
401
403
|
# test
|
|
402
404
|
assert Client.get_switcher().is_on('MY_SWITCHER')
|
|
403
405
|
|
|
404
|
-
def test_remote_client_uses_default_connection_limits():
|
|
406
|
+
def test_remote_client_uses_default_connection_limits(monkeypatch):
|
|
405
407
|
""" Should build the shared remote client using the default connection limit options """
|
|
406
408
|
|
|
407
409
|
# given
|
|
408
|
-
Remote
|
|
409
|
-
Remote
|
|
410
|
+
monkeypatch.setattr(Remote, '_client', None)
|
|
411
|
+
monkeypatch.setattr(Remote, '_client_config', None)
|
|
410
412
|
given_context()
|
|
411
413
|
|
|
412
414
|
# test
|
|
@@ -416,12 +418,12 @@ def test_remote_client_uses_default_connection_limits():
|
|
|
416
418
|
assert pool._max_connections == 100
|
|
417
419
|
assert pool._keepalive_expiry == 30.0
|
|
418
420
|
|
|
419
|
-
def test_remote_client_rebuilds_when_connection_limits_change():
|
|
421
|
+
def test_remote_client_rebuilds_when_connection_limits_change(monkeypatch):
|
|
420
422
|
""" Should rebuild the shared remote client when connection limit options change """
|
|
421
423
|
|
|
422
424
|
# given
|
|
423
|
-
Remote
|
|
424
|
-
Remote
|
|
425
|
+
monkeypatch.setattr(Remote, '_client', None)
|
|
426
|
+
monkeypatch.setattr(Remote, '_client_config', None)
|
|
425
427
|
given_context(options=ContextOptions(
|
|
426
428
|
remote=RemoteOptions(
|
|
427
429
|
max_keepalive_connections=5,
|
|
@@ -139,3 +139,18 @@ class TestSwitcherStub:
|
|
|
139
139
|
|
|
140
140
|
assert switcher.reset_inputs().is_on()
|
|
141
141
|
assert isolated_result is False
|
|
142
|
+
|
|
143
|
+
def test_switcher_stub_multiple_keys(self):
|
|
144
|
+
""" Should allow different bypass values for multiple keys """
|
|
145
|
+
|
|
146
|
+
# given
|
|
147
|
+
switcher1 = Client.get_switcher(self.key)
|
|
148
|
+
switcher2 = Client.get_switcher(self.key + "_2")
|
|
149
|
+
|
|
150
|
+
# test
|
|
151
|
+
Client.assume(self.key).true()
|
|
152
|
+
Client.assume(self.key + "_2").false()
|
|
153
|
+
Client.assume(self.key + "_2").true() # override previous false assumption
|
|
154
|
+
|
|
155
|
+
assert switcher1.is_on()
|
|
156
|
+
assert switcher2.is_on()
|
|
@@ -71,7 +71,7 @@ def test_switcher_test_rolls_back_applied_mocks_when_setup_fails(monkeypatch: py
|
|
|
71
71
|
)
|
|
72
72
|
def decorated_test():
|
|
73
73
|
""" This test should never run because setup fails before execution. """
|
|
74
|
-
|
|
74
|
+
pytest.fail('The decorated test should not run when setup fails.')
|
|
75
75
|
|
|
76
76
|
with pytest.raises(RuntimeError, match='setup failed'):
|
|
77
77
|
decorated_test()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/globals/global_context.py
RENAMED
|
File without changes
|
|
File without changes
|
{switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/globals/global_snapshot.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/snapshot_auto_updater.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/execution_logger.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/timed_match/__init__.py
RENAMED
|
File without changes
|
{switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/timed_match/timed_match.py
RENAMED
|
File without changes
|
{switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client/lib/utils/timed_match/worker.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{switcher_client-1.2.0 → switcher_client-1.2.2}/switcher_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|