Skip to content

Commit

Permalink
test: set test for ui
Browse files Browse the repository at this point in the history
  • Loading branch information
dfguerrerom committed Jun 25, 2024
1 parent 3823ee0 commit fee4ed3
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"""

from pathlib import Path

import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
from jupyter_client.kernelspec import KernelSpecManager
import nox


Expand Down Expand Up @@ -33,6 +35,40 @@ def app(session):
)


@nox.session()
def test_ui(session):
"""Run the application."""

ksm = KernelSpecManager()
kernel_names = list(ksm.get_all_specs())
print(kernel_names)

# get the current path
root_folder = Path(__file__).parent
repo_name = root_folder.name

# Copy the ui.ipynb to test_ui.ipynb
session.run("cp", root_folder / "ui.ipynb", root_folder / "nox_ui.ipynb")

session.run("entry_point", "--test", root_folder / "nox_ui.ipynb")

test_notebooks = [root_folder / "nox_ui.ipynb"]

for notebook in test_notebooks:
with open(notebook) as ff:
nb_in = nbformat.read(ff, nbformat.NO_CONVERT)

print("Running notebook", notebook)

try:
ep = ExecutePreprocessor(timeout=600, kernel_name=f"test-{repo_name}")

nb_out = ep.preprocess(nb_in)
except Exception as e:
print("########### Error running notebook", notebook)
raise e


@nox.session(reuse_venv=True)
def jupyter(session):
"""Run the application."""
Expand Down

0 comments on commit fee4ed3

Please sign in to comment.