Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keine questionpy -> questionpy_sdk dependencies erlauben #145

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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" }
Expand Down
3 changes: 1 addition & 2 deletions questionpy/_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion questionpy_sdk/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
# (c) Technische Universität Berlin, innoCampus <[email protected]>

PACKAGE_CONFIG_FILENAME = "qpy_config.yml"
TEMPLATES_DIR = "templates"
3 changes: 1 addition & 2 deletions questionpy_sdk/package/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_arch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pytest_archon import archrule


def test_questionpy_should_not_import_sdk() -> None:
(
janbritz marked this conversation as resolved.
Show resolved Hide resolved
archrule("questionpy_should_not_import_sdk", comment="The questionpy package must work without the SDK.")
.match("questionpy*")
.should_not_import("questionpy_sdk*")
.check("questionpy")
)
Loading