mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Add tests for the plugin mechanism
This commit is contained in:
@@ -68,10 +68,16 @@ jobs:
|
||||
.circleci/integration-test.py build-image
|
||||
|
||||
- run:
|
||||
name: Run basic tests tests
|
||||
name: Run basic tests
|
||||
command: |
|
||||
.circleci/integration-test.py run-test basic-tests test_hub.py test_install.py test_extensions.py
|
||||
|
||||
- run:
|
||||
name: Run plugin tests
|
||||
command: |
|
||||
.circleci/integration-test.py run-test \
|
||||
--installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \
|
||||
plugins test_simplest_plugin.py
|
||||
|
||||
|
||||
documentation:
|
||||
|
||||
9
integration-tests/plugins/simplest/setup.py
Normal file
9
integration-tests/plugins/simplest/setup.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name="tljh-simplest",
|
||||
entry_points={"tljh": ["simplest = tljh_simplest"]},
|
||||
py_modules=["tljh_simplest"],
|
||||
)
|
||||
|
||||
|
||||
33
integration-tests/plugins/simplest/tljh_simplest.py
Normal file
33
integration-tests/plugins/simplest/tljh_simplest.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""
|
||||
Simplest plugin that excercises all the hooks
|
||||
"""
|
||||
from tljh.hooks import hookimpl
|
||||
|
||||
|
||||
@hookimpl
|
||||
def tljh_extra_user_conda_packages():
|
||||
return [
|
||||
'hypothesis',
|
||||
]
|
||||
|
||||
|
||||
@hookimpl
|
||||
def tljh_extra_user_pip_packages():
|
||||
return [
|
||||
'django',
|
||||
]
|
||||
|
||||
|
||||
@hookimpl
|
||||
def tljh_extra_apt_packages():
|
||||
return [
|
||||
'sl',
|
||||
]
|
||||
|
||||
|
||||
@hookimpl
|
||||
def tljh_config_post_install(config):
|
||||
# Put an arbitrary marker we can test for
|
||||
config['simplest_plugin'] = {
|
||||
'present': True
|
||||
}
|
||||
47
integration-tests/test_simplest_plugin.py
Normal file
47
integration-tests/test_simplest_plugin.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
Test simplest plugin
|
||||
"""
|
||||
from ruamel.yaml import YAML
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
yaml = YAML(typ='rt')
|
||||
|
||||
|
||||
def test_apt_packages():
|
||||
"""
|
||||
Test extra apt packages are installed
|
||||
"""
|
||||
assert os.path.exists('/usr/bin/sl')
|
||||
|
||||
|
||||
def test_pip_packages():
|
||||
"""
|
||||
Test extra user pip packages are installed
|
||||
"""
|
||||
subprocess.check_call([
|
||||
'/opt/tljh/user/bin/python3',
|
||||
'-c',
|
||||
'import django'
|
||||
])
|
||||
|
||||
|
||||
def test_conda_packages():
|
||||
"""
|
||||
Test extra user conda packages are installed
|
||||
"""
|
||||
subprocess.check_call([
|
||||
'/opt/tljh/user/bin/python3',
|
||||
'-c',
|
||||
'import hypothesis'
|
||||
])
|
||||
|
||||
|
||||
def test_config_hook():
|
||||
"""
|
||||
Check config changes are present
|
||||
"""
|
||||
with open('/opt/tljh/config.yaml') as f:
|
||||
data = yaml.load(f)
|
||||
|
||||
assert data['simplest_plugin']['present']
|
||||
Reference in New Issue
Block a user