Skip to content

Commit 02c4134

Browse files
committed
pretty
1 parent fd3e9fb commit 02c4134

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

tests/test_settings.py

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import typing
1+
from typing import Any, Optional
22

33
import pytest
44
from pytest_mock import MockerFixture
@@ -7,32 +7,26 @@
77
from edge_proxy.settings import get_settings, AppSettings
88

99

10-
def test_client_side_key_validation() -> None:
11-
"""
12-
Test that client_side_key is properly validated.
13-
"""
14-
# Valid
15-
AppSettings(
16-
environment_key_pairs=[
17-
{"server_side_key": "ser.abc123", "client_side_key": "def456"}
18-
]
19-
)
20-
21-
# Missing client_side_key
22-
with pytest.raises(ValidationError):
23-
AppSettings(
24-
environment_key_pairs=[
25-
{"server_side_key": "ser.abc123", "client_side_key": ""}
26-
]
27-
)
28-
29-
# Invalid server_side_key
30-
with pytest.raises(ValidationError):
10+
@pytest.mark.parametrize(
11+
"client_side_key,server_side_key,expected_exception",
12+
[
13+
("abc123", "ser.456", None),
14+
("abc123", "456", ValidationError),
15+
("abc123", "", ValidationError),
16+
("", "ser.456", ValidationError),
17+
],
18+
)
19+
def test_client_side_key_validation(
20+
client_side_key: str, server_side_key: str, expected_exception: Optional[Exception]
21+
) -> None:
22+
try:
3123
AppSettings(
3224
environment_key_pairs=[
33-
{"server_side_key": "abc123", "client_side_key": "abc123"}
25+
{"server_side_key": server_side_key, "client_side_key": client_side_key}
3426
]
3527
)
28+
except expected_exception:
29+
pass
3630

3731

3832
@pytest.mark.parametrize(
@@ -64,8 +58,8 @@ def test_client_side_key_validation() -> None:
6458
)
6559
def test_settings_are_loaded_correctly(
6660
mocker: MockerFixture,
67-
config_file_json: dict[str, typing.Any],
68-
expected_config: dict[str, typing.Any],
61+
config_file_json: dict[str, Any],
62+
expected_config: dict[str, Any],
6963
) -> None:
7064
"""
7165
Parametrized test which accepts a raw json config file, and a dictionary representing the

0 commit comments

Comments
 (0)