2018-08-04 10:55:25 -07:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_serverextensions():
|
|
|
|
|
"""
|
|
|
|
|
Validate serverextensions we want are installed
|
|
|
|
|
"""
|
|
|
|
|
# jupyter-serverextension writes to stdout and stderr weirdly
|
2021-11-01 09:42:45 +01:00
|
|
|
proc = subprocess.run(
|
2023-08-01 06:52:56 +00:00
|
|
|
["/opt/tljh/user/bin/jupyter-server", "extension", "list", "--sys-prefix"],
|
2021-11-01 09:42:45 +01:00
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
|
)
|
2018-08-04 10:55:25 -07:00
|
|
|
|
|
|
|
|
extensions = [
|
2023-08-01 06:28:39 +00:00
|
|
|
"jupyterlab",
|
2023-08-01 07:01:58 +00:00
|
|
|
# "nbgitpuller",
|
2021-11-03 23:55:34 +01:00
|
|
|
"jupyter_resource_usage",
|
2018-08-04 10:55:25 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
for e in extensions:
|
2020-02-03 11:07:49 +02:00
|
|
|
assert e in proc.stderr.decode()
|
2018-08-04 10:55:25 -07:00
|
|
|
|
2021-11-01 09:42:45 +01:00
|
|
|
|
2023-08-01 06:43:49 +00:00
|
|
|
def test_labextensions():
|
2018-08-04 10:55:25 -07:00
|
|
|
"""
|
2023-08-01 06:43:49 +00:00
|
|
|
Validate JupyterLab extensions we want are installed & enabled
|
2018-08-04 10:55:25 -07:00
|
|
|
"""
|
2023-08-01 06:43:49 +00:00
|
|
|
# jupyter-labextension writes to stdout and stderr weirdly
|
2021-11-01 09:42:45 +01:00
|
|
|
proc = subprocess.run(
|
2023-08-01 06:43:49 +00:00
|
|
|
["/opt/tljh/user/bin/jupyter-labextension", "list"],
|
2021-11-01 09:42:45 +01:00
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
|
)
|
2018-08-04 10:55:25 -07:00
|
|
|
|
|
|
|
|
extensions = [
|
2023-08-01 06:43:49 +00:00
|
|
|
"@jupyter-server/resource-usage",
|
|
|
|
|
# This is what ipywidgets lab extension is called
|
|
|
|
|
"@jupyter-widgets/jupyterlab-manager",
|
2018-08-04 10:55:25 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
for e in extensions:
|
2023-08-01 07:38:32 +00:00
|
|
|
# jupyter labextension lists outputs to stderr
|
|
|
|
|
out = proc.stderr.decode()
|
|
|
|
|
enabled_ok_pattern = re.compile(fr"{e}.*enabled.*OK")
|
|
|
|
|
matches = enabled_ok_pattern.search(proc.stderr.decode())
|
|
|
|
|
assert matches is not None
|