django-systemd 0.2.3__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/workflows/test.yml +1 -1
- {django_systemd-0.2.3 → django_systemd-0.3.0}/PKG-INFO +3 -2
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/changelog.rst +9 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/settings.rst +12 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/tutorial.rst +10 -8
- {django_systemd-0.2.3 → django_systemd-0.3.0}/pyproject.toml +3 -2
- {django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/__init__.py +1 -1
- {django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/config.py +13 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/management/commands/systemd.py +37 -12
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/test_basics.py +8 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/test_command.py +29 -4
- {django_systemd-0.2.3 → django_systemd-0.3.0}/uv.lock +461 -397
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.codecov.yml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.gitattributes +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/CODEOWNERS +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/dependabot.yml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/workflows/bandit.yml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/workflows/dependabot-automerge.yml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/workflows/lint.yml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/workflows/release.yml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/workflows/scorecard.yml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/workflows/update_coc.yml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/workflows/zizmor.yml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.github/zizmor.yml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.gitignore +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.pre-commit-config.yaml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/.readthedocs.yaml +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/AGENTS.md +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/CODE_OF_CONDUCT.md +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/CONTRIBUTING.md +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/LICENSE +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/README.md +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/SECURITY.md +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/_static/style.css +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/command.rst +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/conf.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/howto.rst +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/index.rst +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/reference/config.rst +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/reference/defines.rst +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/reference/index.rst +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/reference/protocol.rst +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/reference/signals.rst +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/reference/systemd.rst +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/doc/source/refs.rst +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/justfile +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/admin.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/apps.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/defines.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/management/__init__.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/management/commands/__init__.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/protocol.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/signals.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/__init__.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/__init__.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app1/__init__.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app1/systemd/app@.target +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app1/systemd/check.timer +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app1/systemd/web.service +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app2/__init__.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app2/systemd/app@.target +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app2/systemd/check.timer +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app2/systemd/web.service +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app3/__init__.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app3/systemd/bad name.service +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app3/systemd/broken.service +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app3/systemd/cleanup.service +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app3/systemd/cleanup.timer +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app3/systemd/my.app.timer +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app3/systemd/runtime.service +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app3/systemd/scoped.service +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app3/systemd/sub/web.service +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/apps/app3/systemd/web.socket +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/conftest.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/settings.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/test_protocol.py +0 -0
- {django_systemd-0.2.3 → django_systemd-0.3.0}/tests/urls.py +0 -0
|
@@ -287,7 +287,7 @@ jobs:
|
|
|
287
287
|
- run: ls -la *.coverage
|
|
288
288
|
- run: just coverage
|
|
289
289
|
- name: Upload coverage to Codecov
|
|
290
|
-
uses: codecov/codecov-action@
|
|
290
|
+
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5
|
|
291
291
|
with:
|
|
292
292
|
use_oidc: true
|
|
293
293
|
files: ./coverage.xml
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: django-systemd
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Ship renderable systemd unit templates with your apps and manage project services through the django admin.
|
|
5
5
|
Project-URL: Homepage, https://django-systemd.readthedocs.io
|
|
6
6
|
Project-URL: Documentation, https://django-systemd.readthedocs.io
|
|
@@ -34,8 +34,9 @@ Classifier: Topic :: Software Development :: Libraries
|
|
|
34
34
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
35
35
|
Requires-Python: <4.0,>=3.11
|
|
36
36
|
Requires-Dist: django-render-static>=3.5.0
|
|
37
|
-
Requires-Dist: django-typer>=
|
|
37
|
+
Requires-Dist: django-typer>=4
|
|
38
38
|
Requires-Dist: django<6.2,>=5.2
|
|
39
|
+
Requires-Dist: rich>=15.0.0
|
|
39
40
|
Description-Content-Type: text/markdown
|
|
40
41
|
|
|
41
42
|
# django-systemd
|
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
Change Log
|
|
5
5
|
==========
|
|
6
6
|
|
|
7
|
+
v0.3.0 (2026-10-05)
|
|
8
|
+
===================
|
|
9
|
+
|
|
10
|
+
* Added the :setting:`SYSTEMD_RENDER_DIR` setting to change the default
|
|
11
|
+
``render`` output directory from the current directory.
|
|
12
|
+
* ``list`` prints its table with Rich. Output that is not a terminal is never
|
|
13
|
+
wrapped, so piped rows keep one unit per line.
|
|
14
|
+
|
|
15
|
+
|
|
7
16
|
v0.2.3 (2026-09-30)
|
|
8
17
|
===================
|
|
9
18
|
|
|
@@ -162,3 +162,15 @@ early boot; ``install`` creates it with mode ``0755`` before the umask is
|
|
|
162
162
|
applied, if it does not exist.
|
|
163
163
|
|
|
164
164
|
Default: ``None``
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
``SYSTEMD_RENDER_DIR``
|
|
168
|
+
-----------------------
|
|
169
|
+
|
|
170
|
+
.. setting:: SYSTEMD_RENDER_DIR
|
|
171
|
+
|
|
172
|
+
The directory ``render`` writes unit files into when no output directory is
|
|
173
|
+
passed on the command line. A relative path is resolved against the current
|
|
174
|
+
directory. An explicit ``render`` argument always takes precedence.
|
|
175
|
+
|
|
176
|
+
Default: ``None`` (the current directory)
|
|
@@ -233,10 +233,11 @@ directory:
|
|
|
233
233
|
|
|
234
234
|
.. code-block:: text
|
|
235
235
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
236
|
+
UNIT INSTALLED ENABLED ACTIVE SOURCE
|
|
237
|
+
────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
238
|
+
mysite-web.service no - - /srv/mysite/deploy/systemd/mysite-web.service
|
|
239
|
+
mysite-dbcheck.service no - - /srv/mysite/deploy/systemd/mysite-dbcheck.service
|
|
240
|
+
mysite-dbcheck.timer no - - /srv/mysite/deploy/systemd/mysite-dbcheck.timer
|
|
240
241
|
|
|
241
242
|
Nothing is installed yet, so the state columns show ``-``. This command never
|
|
242
243
|
escalates and works anywhere, including a development machine without
|
|
@@ -329,10 +330,11 @@ Check the result:
|
|
|
329
330
|
|
|
330
331
|
.. code-block:: text
|
|
331
332
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
UNIT INSTALLED ENABLED ACTIVE SOURCE
|
|
334
|
+
────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
335
|
+
mysite-web.service yes yes yes /srv/mysite/deploy/systemd/mysite-web.service
|
|
336
|
+
mysite-dbcheck.service yes yes no /srv/mysite/deploy/systemd/mysite-dbcheck.service
|
|
337
|
+
mysite-dbcheck.timer yes yes yes /srv/mysite/deploy/systemd/mysite-dbcheck.timer
|
|
336
338
|
|
|
337
339
|
The web service and the timer are active. The check service is not, which is
|
|
338
340
|
correct: a oneshot service is only active for the moment it runs. Its
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "django-systemd"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Ship renderable systemd unit templates with your apps and manage project services through the django admin."
|
|
9
9
|
requires-python = ">=3.11,<4.0"
|
|
10
10
|
authors = [
|
|
@@ -19,7 +19,8 @@ keywords = ["django", "CLI", "management", "Typer", "commands", "systemd", "serv
|
|
|
19
19
|
dependencies = [
|
|
20
20
|
"Django>=5.2,<6.2",
|
|
21
21
|
"django-render-static>=3.5.0",
|
|
22
|
-
"django-typer>=
|
|
22
|
+
"django-typer>=4",
|
|
23
|
+
"rich>=15.0.0",
|
|
23
24
|
]
|
|
24
25
|
classifiers = [
|
|
25
26
|
"Environment :: Console",
|
|
@@ -190,6 +190,19 @@ def link_dir() -> Path | None:
|
|
|
190
190
|
return path
|
|
191
191
|
|
|
192
192
|
|
|
193
|
+
def render_dir() -> Path | None:
|
|
194
|
+
"""
|
|
195
|
+
The ``SYSTEMD_RENDER_DIR`` setting: the default directory ``render`` writes
|
|
196
|
+
unit files into. A relative path is resolved against the current directory.
|
|
197
|
+
|
|
198
|
+
:return: A :class:`~pathlib.Path`, or ``None`` when unset.
|
|
199
|
+
"""
|
|
200
|
+
from django.conf import settings
|
|
201
|
+
|
|
202
|
+
value = getattr(settings, "SYSTEMD_RENDER_DIR", None)
|
|
203
|
+
return Path(value) if value else None
|
|
204
|
+
|
|
205
|
+
|
|
193
206
|
@cache
|
|
194
207
|
def template_engine_config() -> dict[str, t.Any]:
|
|
195
208
|
"""
|
{django_systemd-0.2.3 → django_systemd-0.3.0}/src/django_systemd/management/commands/systemd.py
RENAMED
|
@@ -33,6 +33,9 @@ from django.core.exceptions import ImproperlyConfigured
|
|
|
33
33
|
from django.core.management import CommandError
|
|
34
34
|
from django.template import TemplateDoesNotExist, TemplateSyntaxError
|
|
35
35
|
from django_typer.management import TyperCommand, command, initialize
|
|
36
|
+
from rich import box
|
|
37
|
+
from rich.console import Console
|
|
38
|
+
from rich.table import Table
|
|
36
39
|
|
|
37
40
|
from django_systemd.config import (
|
|
38
41
|
ServiceUnit,
|
|
@@ -40,6 +43,7 @@ from django_systemd.config import (
|
|
|
40
43
|
install_method,
|
|
41
44
|
link_dir,
|
|
42
45
|
project_units,
|
|
46
|
+
render_dir,
|
|
43
47
|
render_engine,
|
|
44
48
|
)
|
|
45
49
|
from django_systemd.config import scope as settings_scope
|
|
@@ -106,6 +110,13 @@ def parse_context(pairs: list[str]) -> dict[str, str]:
|
|
|
106
110
|
return context
|
|
107
111
|
|
|
108
112
|
|
|
113
|
+
def _state(value: bool | None) -> str:
|
|
114
|
+
"""Rich markup for a yes/no unit state; ``None`` means it was not queried."""
|
|
115
|
+
if value is None:
|
|
116
|
+
return "[dim]-[/dim]"
|
|
117
|
+
return "[green]yes[/green]" if value else "[dim]no[/dim]"
|
|
118
|
+
|
|
119
|
+
|
|
109
120
|
class Command(TyperCommand):
|
|
110
121
|
"""
|
|
111
122
|
The ``systemd`` management command: list, render, install, uninstall,
|
|
@@ -256,24 +267,35 @@ class Command(TyperCommand):
|
|
|
256
267
|
if not self.units:
|
|
257
268
|
typer.echo("No systemd unit templates found.")
|
|
258
269
|
return
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
)
|
|
270
|
+
table = Table(box=box.SIMPLE_HEAD, header_style="bold")
|
|
271
|
+
table.add_column("UNIT", no_wrap=True)
|
|
272
|
+
table.add_column("INSTALLED")
|
|
273
|
+
table.add_column("ENABLED")
|
|
274
|
+
table.add_column("ACTIVE")
|
|
275
|
+
table.add_column("SOURCE", overflow="fold")
|
|
263
276
|
available = self.ctl.available
|
|
264
277
|
for unit in self.units:
|
|
265
278
|
installed = self.ctl.is_installed(unit.filename)
|
|
266
|
-
enabled = active =
|
|
279
|
+
enabled = active = None
|
|
267
280
|
if installed and available and not unit.instanceable:
|
|
268
281
|
try:
|
|
269
|
-
enabled =
|
|
270
|
-
active =
|
|
282
|
+
enabled = self.ctl.is_enabled(unit.filename)
|
|
283
|
+
active = self.ctl.is_active(unit.filename)
|
|
271
284
|
except subprocess.CalledProcessError as err:
|
|
272
285
|
raise CommandError(describe_failure(err)) from err
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
286
|
+
table.add_row(
|
|
287
|
+
unit.filename,
|
|
288
|
+
_state(installed),
|
|
289
|
+
_state(enabled),
|
|
290
|
+
_state(active),
|
|
291
|
+
str(unit.path),
|
|
276
292
|
)
|
|
293
|
+
console = Console()
|
|
294
|
+
if not console.is_terminal:
|
|
295
|
+
# Piped or captured output is read by tools, not people: never fold
|
|
296
|
+
# paths to a guessed width.
|
|
297
|
+
console = Console(width=max(console.width, 10_000))
|
|
298
|
+
console.print(table)
|
|
277
299
|
|
|
278
300
|
def _context(self, pairs: list[str] | None) -> dict[str, str]:
|
|
279
301
|
"""Parse --context overrides, refusing an override of the scope."""
|
|
@@ -288,13 +310,16 @@ class Command(TyperCommand):
|
|
|
288
310
|
output_dir: Annotated[
|
|
289
311
|
Path | None,
|
|
290
312
|
typer.Argument(
|
|
291
|
-
help="Directory to render unit files into. Defaults to the
|
|
313
|
+
help="Directory to render unit files into. Defaults to the "
|
|
314
|
+
"SYSTEMD_RENDER_DIR setting, or the current directory if unset."
|
|
292
315
|
),
|
|
293
316
|
] = None,
|
|
294
317
|
context: ContextOption = None,
|
|
295
318
|
) -> None:
|
|
296
319
|
"""Render this project's unit templates to a directory."""
|
|
297
|
-
rendered = self.render_units(
|
|
320
|
+
rendered = self.render_units(
|
|
321
|
+
output_dir or render_dir() or Path("."), self._context(context)
|
|
322
|
+
)
|
|
298
323
|
for _, path in rendered:
|
|
299
324
|
typer.echo(str(path))
|
|
300
325
|
|
|
@@ -18,6 +18,7 @@ from django_systemd.config import (
|
|
|
18
18
|
install_method,
|
|
19
19
|
link_dir,
|
|
20
20
|
project_units,
|
|
21
|
+
render_dir,
|
|
21
22
|
render_engine,
|
|
22
23
|
scope,
|
|
23
24
|
template_engine_config,
|
|
@@ -491,6 +492,13 @@ class TestInstallMethodSettings:
|
|
|
491
492
|
def test_defaults(self):
|
|
492
493
|
assert install_method() is InstallMethod.COPY
|
|
493
494
|
assert link_dir() is None
|
|
495
|
+
assert render_dir() is None
|
|
496
|
+
|
|
497
|
+
def test_render_dir_setting(self, tmp_path):
|
|
498
|
+
with override_settings(SYSTEMD_RENDER_DIR=str(tmp_path)):
|
|
499
|
+
assert render_dir() == tmp_path
|
|
500
|
+
with override_settings(SYSTEMD_RENDER_DIR=tmp_path):
|
|
501
|
+
assert render_dir() == tmp_path
|
|
494
502
|
|
|
495
503
|
def test_link_settings(self, tmp_path):
|
|
496
504
|
with override_settings(
|
|
@@ -622,7 +622,9 @@ class TestList:
|
|
|
622
622
|
call_command("systemd", "list")
|
|
623
623
|
out = capsys.readouterr().out
|
|
624
624
|
assert fake_ctl.calls == []
|
|
625
|
-
row = next(
|
|
625
|
+
row = next(
|
|
626
|
+
line for line in out.splitlines() if line.strip().startswith("web.service")
|
|
627
|
+
)
|
|
626
628
|
assert row.split()[1:4] == ["no", "-", "-"]
|
|
627
629
|
|
|
628
630
|
def test_installed_rows_show_state(self, fake_ctl, capsys):
|
|
@@ -631,7 +633,9 @@ class TestList:
|
|
|
631
633
|
fake_ctl.active.add("web.service")
|
|
632
634
|
call_command("systemd", "list")
|
|
633
635
|
out = capsys.readouterr().out
|
|
634
|
-
row = next(
|
|
636
|
+
row = next(
|
|
637
|
+
line for line in out.splitlines() if line.strip().startswith("web.service")
|
|
638
|
+
)
|
|
635
639
|
assert row.split()[1:4] == ["yes", "no", "yes"]
|
|
636
640
|
|
|
637
641
|
def test_instanceable_units_are_never_queried(self, fake_ctl, capsys):
|
|
@@ -639,7 +643,9 @@ class TestList:
|
|
|
639
643
|
(fake_ctl.unit_dir / "app@.target").write_text("x")
|
|
640
644
|
call_command("systemd", "list")
|
|
641
645
|
out = capsys.readouterr().out
|
|
642
|
-
row = next(
|
|
646
|
+
row = next(
|
|
647
|
+
line for line in out.splitlines() if line.strip().startswith("app@.target")
|
|
648
|
+
)
|
|
643
649
|
assert row.split()[1:4] == ["yes", "-", "-"]
|
|
644
650
|
assert fake_ctl.calls == []
|
|
645
651
|
|
|
@@ -658,7 +664,7 @@ class TestList:
|
|
|
658
664
|
row = next(
|
|
659
665
|
line
|
|
660
666
|
for line in capsys.readouterr().out.splitlines()
|
|
661
|
-
if line.startswith("web.service")
|
|
667
|
+
if line.strip().startswith("web.service")
|
|
662
668
|
)
|
|
663
669
|
assert row.split()[1:4] == ["yes", "-", "-"]
|
|
664
670
|
|
|
@@ -678,6 +684,25 @@ class TestRender:
|
|
|
678
684
|
call_command("systemd", "render")
|
|
679
685
|
assert (tmp_path / "web.service").is_file()
|
|
680
686
|
|
|
687
|
+
def test_default_dir_from_setting(self, fake_ctl, tmp_path, monkeypatch):
|
|
688
|
+
monkeypatch.chdir(tmp_path)
|
|
689
|
+
with override_settings(SYSTEMD_RENDER_DIR=str(tmp_path / "units")):
|
|
690
|
+
call_command("systemd", "render")
|
|
691
|
+
assert (tmp_path / "units" / "web.service").is_file()
|
|
692
|
+
assert not (tmp_path / "web.service").exists()
|
|
693
|
+
|
|
694
|
+
def test_relative_setting_is_relative_to_cwd(self, fake_ctl, tmp_path, monkeypatch):
|
|
695
|
+
monkeypatch.chdir(tmp_path)
|
|
696
|
+
with override_settings(SYSTEMD_RENDER_DIR="units"):
|
|
697
|
+
call_command("systemd", "render")
|
|
698
|
+
assert (tmp_path / "units" / "web.service").is_file()
|
|
699
|
+
|
|
700
|
+
def test_argument_overrides_setting(self, fake_ctl, tmp_path):
|
|
701
|
+
with override_settings(SYSTEMD_RENDER_DIR=str(tmp_path / "units")):
|
|
702
|
+
call_command("systemd", "render", str(tmp_path / "explicit"))
|
|
703
|
+
assert (tmp_path / "explicit" / "web.service").is_file()
|
|
704
|
+
assert not (tmp_path / "units").exists()
|
|
705
|
+
|
|
681
706
|
def test_highest_precedence_content(self, fake_ctl, tmp_path):
|
|
682
707
|
call_command("systemd", "render", str(tmp_path))
|
|
683
708
|
assert "app2 override" in (tmp_path / "web.service").read_text()
|