Skip to content

Commit c081dee

Browse files
committed
Updated and enhanced existing tests
1 parent 0d8e079 commit c081dee

1 file changed

Lines changed: 51 additions & 18 deletions

File tree

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,57 @@
11
"""Unit tests for QuotaHandlersConfiguration model."""
22

3+
# pylint: disable=no-member
4+
from typing import Any
5+
6+
import pytest
7+
from pydantic import ValidationError
8+
from pytest_subtests import SubTests
9+
310
from models.config import QuotaHandlersConfiguration, QuotaSchedulerConfiguration
411

512

6-
def test_quota_handlers_configuration() -> None:
13+
def test_quota_handlers_configuration(subtests: SubTests) -> None:
714
"""Test the quota handlers configuration."""
8-
cfg = QuotaHandlersConfiguration(
9-
sqlite=None,
10-
postgres=None,
11-
limiters=[],
12-
scheduler=QuotaSchedulerConfiguration(
13-
database_reconnection_count=10,
14-
database_reconnection_delay=60,
15-
period=10,
16-
),
17-
enable_token_history=False,
18-
)
19-
assert cfg is not None
20-
assert cfg.sqlite is None
21-
assert cfg.postgres is None
22-
assert cfg.limiters == []
23-
assert cfg.scheduler is not None
24-
assert not cfg.enable_token_history
15+
with subtests.test(msg="Token history disabled"):
16+
cfg = QuotaHandlersConfiguration(
17+
sqlite=None,
18+
postgres=None,
19+
limiters=[],
20+
scheduler=QuotaSchedulerConfiguration(
21+
database_reconnection_count=10,
22+
database_reconnection_delay=60,
23+
period=10,
24+
),
25+
enable_token_history=False,
26+
)
27+
assert cfg is not None
28+
assert cfg.sqlite is None
29+
assert cfg.postgres is None
30+
assert cfg.limiters == []
31+
assert cfg.scheduler is not None
32+
assert cfg.scheduler.database_reconnection_count == 10
33+
assert cfg.scheduler.database_reconnection_delay == 60
34+
assert cfg.scheduler.period == 10
35+
assert not cfg.enable_token_history
36+
37+
with subtests.test(msg="Token history enabled"):
38+
cfg = QuotaHandlersConfiguration(
39+
sqlite=None,
40+
postgres=None,
41+
limiters=[],
42+
scheduler=QuotaSchedulerConfiguration(
43+
database_reconnection_count=10,
44+
database_reconnection_delay=60,
45+
period=10,
46+
),
47+
enable_token_history=True,
48+
)
49+
assert cfg is not None
50+
assert cfg.sqlite is None
51+
assert cfg.postgres is None
52+
assert cfg.limiters == []
53+
assert cfg.scheduler is not None
54+
assert cfg.scheduler.database_reconnection_count == 10
55+
assert cfg.scheduler.database_reconnection_delay == 60
56+
assert cfg.scheduler.period == 10
57+
assert cfg.enable_token_history

0 commit comments

Comments
 (0)