-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
deb9113
commit b27a3c1
Showing
2 changed files
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import json | ||
import typing | ||
|
||
import pytest | ||
|
||
from src.edge_proxy.settings import AppConfig | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"config_file_raw_json, settings_tests", | ||
( | ||
( | ||
json.dumps( | ||
{ | ||
"environment_key_pairs": [ | ||
{"server_side_key": "abc123", "client_side_key": "ser.def456"} | ||
], | ||
"api_poll_frequency": 10, | ||
"api_poll_timeout": 10, | ||
"api_url": "https://api.flagsmith.com/api/v1", | ||
}, | ||
), | ||
{"api_poll_frequency_seconds": 10, "api_poll_timeout_seconds": 10}, | ||
), | ||
( | ||
json.dumps( | ||
{ | ||
"environment_key_pairs": [ | ||
{"server_side_key": "abc123", "client_side_key": "ser.def456"} | ||
], | ||
"api_poll_frequency_seconds": 10, | ||
"api_poll_timeout_seconds": 10, | ||
"api_url": "https://api.flagsmith.com/api/v1", | ||
} | ||
), | ||
{"api_poll_frequency_seconds": 10, "api_poll_timeout_seconds": 10}, | ||
), | ||
), | ||
) | ||
def test_settings_are_loaded_correctly( | ||
mock_json_config_file: typing.Callable[[str], None], | ||
config_file_raw_json: str, | ||
settings_tests: dict[str, typing.Any], | ||
) -> None: | ||
""" | ||
Parametrized test which accepts a raw json config file, and a dictionary representing the | ||
specific tests that are required against the resulting config. | ||
""" | ||
|
||
# Given | ||
mock_json_config_file(config_file_raw_json) | ||
|
||
# When | ||
config = AppConfig() | ||
|
||
# Then | ||
for key, value in settings_tests.items(): | ||
assert getattr(config, key) == value |