diff --git a/poetry.lock b/poetry.lock index c6857b39..3eb163d7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1265,6 +1265,23 @@ pytest-asyncio = ">=0.17.2" [package.extras] testing = ["coverage (==6.2)", "mypy (==0.931)"] +[[package]] +name = "pytest-archon" +version = "0.0.6" +description = "Rule your architecture like a real developer" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pytest-archon-0.0.6.tar.gz", hash = "sha256:5af260a7617fc0a9e8bcd7a62adc42ed1ad466e20ae128b218589f49f73b1bcf"}, + {file = "pytest_archon-0.0.6-py3-none-any.whl", hash = "sha256:f49b6b1f33a541dda1cab8a733b93b8a712594a002f03283294a624d0b394e83"}, +] + +[package.dependencies] +pytest = ">=7.2" + +[package.extras] +dev = ["black", "check-manifest", "check-wheel-contents", "coverage", "flake8", "mypy", "pyroma"] + [[package]] name = "pytest-asyncio" version = "0.24.0" @@ -1770,4 +1787,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "541327434d7d3eabae4e0936e1dd88bf63462b363b733376ce5ed5d852cc668d" +content-hash = "13b7eb3dda4a28354933ed63c0ffe0a24fbd1f720e6befca42bfc22750d9d905" diff --git a/pyproject.toml b/pyproject.toml index 3e775634..c7649106 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ pytest-md = "^0.2.0" coverage = { extras = ["toml"], version = "^7.4.4" } selenium = "^4.19.0" lxml-stubs = "^0.5.1" +pytest-archon = "^0.0.6" [tool.poetry.group.linter] dependencies = { ruff = "^0.6.3" } diff --git a/questionpy/_ui.py b/questionpy/_ui.py index 1cd92557..d684e635 100644 --- a/questionpy/_ui.py +++ b/questionpy/_ui.py @@ -6,7 +6,6 @@ import jinja2 from questionpy_common.environment import Package, PackageNamespaceAndShortName, get_qpy_environment -from questionpy_sdk.constants import TEMPLATES_DIR if TYPE_CHECKING: from questionpy import Attempt, Question @@ -46,7 +45,7 @@ def get_source(self, environment: jinja2.Environment, template: str) -> tuple[st def _get_loader(package: Package) -> jinja2.BaseLoader | None: - templates_directory = package.get_path(f"{TEMPLATES_DIR}/") + templates_directory = package.get_path("templates/") if not templates_directory.is_dir(): # The package has no "templates" directory which would cause a template loader to raise an unhelpful ValueError. diff --git a/questionpy_sdk/constants.py b/questionpy_sdk/constants.py index 7da73181..faa69cd5 100644 --- a/questionpy_sdk/constants.py +++ b/questionpy_sdk/constants.py @@ -3,4 +3,3 @@ # (c) Technische Universität Berlin, innoCampus PACKAGE_CONFIG_FILENAME = "qpy_config.yml" -TEMPLATES_DIR = "templates" diff --git a/questionpy_sdk/package/builder.py b/questionpy_sdk/package/builder.py index cd6295b9..684fb29b 100644 --- a/questionpy_sdk/package/builder.py +++ b/questionpy_sdk/package/builder.py @@ -19,7 +19,6 @@ import questionpy from questionpy_common.constants import DIST_DIR, MANIFEST_FILENAME from questionpy_common.manifest import Manifest, PackageFile -from questionpy_sdk.constants import TEMPLATES_DIR from questionpy_sdk.models import BuildHookName from questionpy_sdk.package.errors import PackageBuildError from questionpy_sdk.package.source import PackageSource @@ -103,7 +102,7 @@ def _write_package_files(self) -> None: """Writes custom package files.""" static_path = Path(DIST_DIR) / "static" self._write_glob(self._source.path, "python/**/*", DIST_DIR) - self._write_glob(self._source.path, f"{TEMPLATES_DIR}/**/*", DIST_DIR) + self._write_glob(self._source.path, "templates/**/*", DIST_DIR) self._write_glob(self._source.path, "css/**/*", static_path, add_to_static_files=True) self._write_glob(self._source.path, "js/**/*", static_path, add_to_static_files=True) self._write_glob(self._source.path, "static/**/*", DIST_DIR, add_to_static_files=True) diff --git a/tests/test_arch.py b/tests/test_arch.py new file mode 100644 index 00000000..f48f91f7 --- /dev/null +++ b/tests/test_arch.py @@ -0,0 +1,10 @@ +from pytest_archon import archrule + + +def test_questionpy_should_not_import_sdk() -> None: + ( + archrule("questionpy_should_not_import_sdk", comment="The questionpy package must work without the SDK.") + .match("questionpy*") + .should_not_import("questionpy_sdk*") + .check("questionpy") + )