Skip to content

Commit a897051

Browse files
committed
Add test for the nox.default module
Also creates a `tests.utils` module to store common test utilities. For now it only provides a common error message for when the repository types handled don't match the expectation. Some `__init__.py` files are added to `tests/` to be able to use relative imports. Signed-off-by: Leandro Lucarella <leandro.lucarella@frequenz.com>
1 parent 2be9e70 commit a897051

4 files changed

Lines changed: 47 additions & 0 deletions

File tree

tests/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License: MIT
2+
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Tests for the repository."""

tests/nox/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License: MIT
2+
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Tests for the nox package."""

tests/nox/test_default.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# License: MIT
2+
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Tests for the nox.default module."""
5+
6+
from frequenz.repo import config
7+
from frequenz.repo.config.nox import default
8+
9+
from .. import utils
10+
11+
12+
def test_all_repository_types_are_handled() -> None:
13+
"""Test that all repository types handled match the defined in RepositoryType."""
14+
expected = {
15+
*{f"{repo_type.value}_config" for repo_type in config.RepositoryType},
16+
*{f"{repo_type.value}_command_options" for repo_type in config.RepositoryType},
17+
"common_config",
18+
"common_command_options",
19+
}
20+
21+
defined = {
22+
f
23+
for f in dir(default)
24+
if not f.startswith("_")
25+
and (f.endswith("_config") or f.endswith("_command_options"))
26+
}
27+
assert defined == expected, utils.MSG_UNEXPECTED_REPO_TYPES

tests/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# License: MIT
2+
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Test utilities."""
5+
6+
MSG_UNEXPECTED_REPO_TYPES = """\
7+
Missing (or unexpected) repository types. Please make sure update:
8+
9+
- the documentation (in particular in src/frequenz/repo/config/__init__.py)
10+
- the code (including all packages)
11+
- the tests
12+
"""

0 commit comments

Comments
 (0)