Skip to content

Commit d8e504b

Browse files
authored
Merge pull request #827 from tisnik/lcore-1028-unit-tests-for-quota-scheduler-configuration-model
LCORE-1028: unit tests for quota scheduler configuration model
2 parents a8bc9a1 + 70bea89 commit d8e504b

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

tests/unit/models/config/test_authentication_configuration.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def test_authentication_configuration_rh_identity() -> None:
6464
assert auth_config.k8s_ca_cert_path is None
6565
assert auth_config.k8s_cluster_api is None
6666
assert auth_config.rh_identity_config is not None
67+
assert auth_config.rh_identity_configuration is auth_config.rh_identity_config
68+
assert auth_config.rh_identity_configuration.required_entitlements == []
6769

6870

6971
def test_authentication_configuration_rh_identity_default_value() -> None:
@@ -82,6 +84,8 @@ def test_authentication_configuration_rh_identity_default_value() -> None:
8284
assert auth_config.k8s_ca_cert_path is None
8385
assert auth_config.k8s_cluster_api is None
8486
assert auth_config.rh_identity_config is not None
87+
assert auth_config.rh_identity_configuration is auth_config.rh_identity_config
88+
assert auth_config.rh_identity_configuration.required_entitlements is None
8589

8690

8791
def test_authentication_configuration_rh_identity_one_entitlement() -> None:
@@ -100,6 +104,8 @@ def test_authentication_configuration_rh_identity_one_entitlement() -> None:
100104
assert auth_config.k8s_ca_cert_path is None
101105
assert auth_config.k8s_cluster_api is None
102106
assert auth_config.rh_identity_config is not None
107+
assert auth_config.rh_identity_configuration is auth_config.rh_identity_config
108+
assert auth_config.rh_identity_configuration.required_entitlements == ["foo"]
103109

104110

105111
def test_authentication_configuration_rh_identity_more_entitlements() -> None:
@@ -120,12 +126,20 @@ def test_authentication_configuration_rh_identity_more_entitlements() -> None:
120126
assert auth_config.k8s_ca_cert_path is None
121127
assert auth_config.k8s_cluster_api is None
122128
assert auth_config.rh_identity_config is not None
129+
assert auth_config.rh_identity_configuration is auth_config.rh_identity_config
130+
assert auth_config.rh_identity_configuration.required_entitlements == [
131+
"foo",
132+
"bar",
133+
"baz",
134+
]
123135

124136

125137
def test_authentication_configuration_rh_identity_but_insufficient_config() -> None:
126138
"""Test the AuthenticationConfiguration with RH identity token."""
127139

128-
with pytest.raises(ValidationError, match="RH"):
140+
with pytest.raises(
141+
ValidationError, match="RH Identity configuration must be specified"
142+
):
129143
AuthenticationConfiguration(
130144
module=AUTH_MOD_RH_IDENTITY,
131145
skip_tls_verification=False,

tests/unit/models/config/test_quota_scheduler_config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
"""Unit tests for QuotaSchedulerConfig model."""
22

3+
import pytest
4+
5+
from pydantic import ValidationError
6+
37
from models.config import QuotaSchedulerConfiguration
48

59

@@ -16,3 +20,15 @@ def test_quota_scheduler_custom_configuration() -> None:
1620
cfg = QuotaSchedulerConfiguration(period=10)
1721
assert cfg is not None
1822
assert cfg.period == 10
23+
24+
25+
def test_quota_scheduler_custom_configuration_zero_period() -> None:
26+
"""Test that zero period value raises ValidationError."""
27+
with pytest.raises(ValidationError, match="Input should be greater than 0"):
28+
QuotaSchedulerConfiguration(period=0)
29+
30+
31+
def test_quota_scheduler_custom_configuration_negative_period() -> None:
32+
"""Test that negative period value raises ValidationError."""
33+
with pytest.raises(ValidationError, match="Input should be greater than 0"):
34+
QuotaSchedulerConfiguration(period=-10)

0 commit comments

Comments
 (0)