Simplify test for the tljh_post_install hook

This commit is contained in:
Jeremy Tuloup
2019-07-02 12:53:06 +02:00
parent f3232e7c44
commit b96a760aee
2 changed files with 7 additions and 20 deletions

View File

@@ -1,9 +1,6 @@
""" """
Simplest plugin that exercises all the hooks Simplest plugin that exercises all the hooks
""" """
from textwrap import dedent
from tljh import systemd
from tljh.hooks import hookimpl from tljh.hooks import hookimpl
@@ -47,17 +44,5 @@ def tljh_custom_jupyterhub_config(c):
@hookimpl @hookimpl
def tljh_post_install(): def tljh_post_install():
post_install_service = dedent(""" with open('test_post_install', 'w') as f:
[Unit] f.write('123456789')
Description=Post Install Test Service
[Service]
ExecStart=ls
[Install]
WantedBy=multi-user.target
""")
service = "post-install-test.service"
systemd.install_unit(service, post_install_service)
systemd.enable_service(service)
systemd.reload_daemon()

View File

@@ -6,7 +6,6 @@ import requests
import os import os
import subprocess import subprocess
from tljh.config import CONFIG_FILE, USER_ENV_PREFIX, HUB_ENV_PREFIX from tljh.config import CONFIG_FILE, USER_ENV_PREFIX, HUB_ENV_PREFIX
from tljh.systemd import check_service_enabled
yaml = YAML(typ='rt') yaml = YAML(typ='rt')
@@ -67,6 +66,9 @@ def test_jupyterhub_config_hook():
def test_post_install_hook(): def test_post_install_hook():
""" """
Test that the post-install-test systemd service is enabled Test that the test_post_install file has the correct content
""" """
assert check_service_enabled("post-install-test") with open("test_post_install") as f:
content = f.read()
assert content == "123456789"