Skip to content

Commit

Permalink
test: common and worker runtime dependencies
Browse files Browse the repository at this point in the history
common should only depend on pydantic and
worker runtime should only depend on pydantic and common
  • Loading branch information
janbritz committed Jan 13, 2025
1 parent f05b5e8 commit 7b88a55
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
19 changes: 18 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pytest = "^8.1.1"
pytest-aiohttp = "^1.0.5"
pytest-md = "^0.2.0"
coverage = { extras = ["toml"], version = "^7.4.4" }
pytest-archon = "^0.0.6"

[tool.poetry.group.linter]
dependencies = { ruff = "^0.6.3" }
Expand Down
33 changes: 33 additions & 0 deletions tests/test_arch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys

from pytest_archon import archrule

import questionpy_common
import questionpy_server.worker.runtime

STD_MODULES_PATTERN = [f"{module}*" for module in sys.stdlib_module_names]


def test_questionpy_common_should_only_import_pydantic() -> None:
(
archrule("questionpy_common_should_only_import_pydantic")
.match("*")
.should_not_import("*")
.may_import(*STD_MODULES_PATTERN)
.may_import("pydantic*")
.may_import("questionpy_common*")
.check(questionpy_common)
)


def test_questionpy_worker_runtime_should_only_import_pydantic_and_questionpy_common() -> None:
(
archrule("questionpy_worker_runtime_should_only_import_pydantic_and_questionpy_common")
.match("*")
.should_not_import("*")
.may_import(*STD_MODULES_PATTERN)
.may_import("pydantic*")
.may_import("questionpy_common*")
.may_import("questionpy_server.worker.runtime*")
.check(questionpy_server.worker.runtime)
)

0 comments on commit 7b88a55

Please sign in to comment.