From 7c417cf2d33fe5df968b33a5b8011b0eca5b77a2 Mon Sep 17 00:00:00 2001 From: Dor Harpaz Date: Thu, 6 Jun 2024 13:24:27 +0300 Subject: [PATCH] Test notebooks --- .github/workflows/run_tests.yml | 3 +++ tests/test_notebooks.py | 10 ++++++++++ tests/utils_for_tests.py | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/test_notebooks.py diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 6b81f7b4..355da234 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -42,6 +42,9 @@ jobs: echo "LIST_OF_IPYNB_CHANGED=None" >> $GITHUB_ENV fi + - name: Set authentication + run: echo "${{ secrets.CLASSIQ_CREDENTIALS_B64 }}" | base64 --decode > "${HOME}/.classiq-credentials" + - name: "Run tests" run: python -m pytest tests env: diff --git a/tests/test_notebooks.py b/tests/test_notebooks.py new file mode 100644 index 00000000..d930abb4 --- /dev/null +++ b/tests/test_notebooks.py @@ -0,0 +1,10 @@ +from testbook import testbook # type: ignore[import] +from utils_for_tests import iterate_notebooks + +TIMEOUT: int = 60 * 3 # 3 minutes + + +def test_notebooks() -> None: + for notebook_path in iterate_notebooks(): + with testbook(notebook_path, execute=True, timeout=TIMEOUT): + pass # we simply wish it to run without errors diff --git a/tests/utils_for_tests.py b/tests/utils_for_tests.py index f2f80fb5..9ea9dd19 100644 --- a/tests/utils_for_tests.py +++ b/tests/utils_for_tests.py @@ -2,7 +2,7 @@ from collections.abc import Iterable from pathlib import Path -ROOT_DIRECTORY = Path(__file__).parent +ROOT_DIRECTORY = Path(__file__).parents[1] def iterate_notebooks() -> Iterable[str]: