2023-08-01 07:40:29 +00:00
|
|
|
import re
|
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"],
|
2025-03-07 16:41:09 -05:00
|
|
|
capture_output=True,
|
|
|
|
|
text=True,
|
2021-11-01 09:42:45 +01:00
|
|
|
)
|
2018-08-04 10:55:25 -07:00
|
|
|
|
2025-03-07 16:41:09 -05:00
|
|
|
output = proc.stdout + proc.stderr
|
|
|
|
|
|
2018-08-04 10:55:25 -07:00
|
|
|
extensions = [
|
2023-08-01 06:28:39 +00:00
|
|
|
"jupyterlab",
|
2023-08-09 05:25:21 +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:
|
2025-03-07 16:41:09 -05:00
|
|
|
assert e in output, f"'{e}' not found in server extensions: {output}"
|
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"],
|
2024-09-20 22:11:25 +02:00
|
|
|
capture_output=True,
|
2021-11-01 09:42:45 +01:00
|
|
|
)
|
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()
|
2023-08-01 07:39:10 +00:00
|
|
|
enabled_ok_pattern = re.compile(rf"{e}.*enabled.*OK")
|
2023-08-01 07:38:54 +00:00
|
|
|
matches = enabled_ok_pattern.search(out)
|
2023-08-01 07:38:32 +00:00
|
|
|
assert matches is not None
|