-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1339 from whylabs/client-cache-refactor
Factor out the whylabs client cache so sessions can use it
- Loading branch information
Showing
13 changed files
with
774 additions
and
237 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
36 changes: 36 additions & 0 deletions
36
python/tests/api/whylabs/session/test_whylabs_client_cache.py
This file contains 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,36 @@ | ||
from whylogs.api.whylabs.session.whylabs_client_cache import ClientCacheConfig | ||
|
||
|
||
def test_empty_cache_key_works() -> None: | ||
cache = dict() | ||
|
||
key1 = ClientCacheConfig() | ||
cache[key1] = 1 | ||
|
||
key2 = ClientCacheConfig() | ||
cache[key2] = 2 | ||
|
||
assert len(cache) == 1 | ||
assert cache[key1] == 2 | ||
|
||
|
||
def test_cache_key_works() -> None: | ||
cache = dict() | ||
|
||
key1 = ClientCacheConfig( | ||
api_key="api_key", endpoint_hostname="endpoint_hostname", whylabs_api_endpoint="whylabs_api_endpoint" | ||
) | ||
cache[key1] = 1 | ||
|
||
key2 = ClientCacheConfig( | ||
api_key="api_key", endpoint_hostname="endpoint_hostname", whylabs_api_endpoint="whylabs_api_endpoint" | ||
) | ||
cache[key2] = 2 | ||
|
||
key3 = ClientCacheConfig(api_key="api_key") | ||
cache[key3] = 3 | ||
|
||
assert len(cache) == 2 | ||
assert cache[key1] == 2 | ||
assert cache[key2] == 2 | ||
assert cache[key3] == 3 |
Oops, something went wrong.