diff --git a/noxfile.py b/noxfile.py index 0320a79..08bf258 100644 --- a/noxfile.py +++ b/noxfile.py @@ -4,7 +4,9 @@ """ from pathlib import Path - +import nbformat +from nbconvert.preprocessors import ExecutePreprocessor +from jupyter_client.kernelspec import KernelSpecManager import nox @@ -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."""