diff --git a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/script_languages_container/utils/slc_ui.ipynb b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/script_languages_container/utils/slc_ui.ipynb index ea8f6b4f..00bb2cb1 100644 --- a/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/script_languages_container/utils/slc_ui.ipynb +++ b/exasol/ds/sandbox/runtime/ansible/roles/jupyter/files/notebook/script_languages_container/utils/slc_ui.ipynb @@ -140,6 +140,8 @@ " \"\"\"\n", " Creates a UI form for choosing the existing script-languages repository.\n", " \"\"\"\n", + " if clone_slc_repo(conf):\n", + " return\n", " default_src_dir = conf.get(AILabConfig.slc_target_dir, '')\n", " select_default = True if default_src_dir else False\n", " src_dir_chooser_widget = FileChooser(path=default_src_dir, select_default=select_default)\n", diff --git a/test/notebooks/nbtest_script_languages_container.py b/test/notebooks/nbtest_script_languages_container.py index 2bbb1f94..4fb6b1e3 100644 --- a/test/notebooks/nbtest_script_languages_container.py +++ b/test/notebooks/nbtest_script_languages_container.py @@ -1,5 +1,4 @@ import os -import textwrap from pathlib import Path import pytest @@ -12,29 +11,63 @@ from exasol.nb_connector.secret_store import Secrets -def _store_slc_config(store_path: Path, store_password: str, target_dir: Path): +def _slc_repo_dir() -> Path: + return Path.cwd() / "script_languages_release" + +def _store_slc_config(store_path: Path, store_password: str, clone_repo: bool): + + slc_source = "Clone script languages release repository" if clone_repo else "Use existing repository" conf = Secrets(store_path, store_password) conf.connection() - conf.save(CKey.slc_source, "Clone script languages release repository") - conf.save(CKey.slc_target_dir, str(target_dir)) - -@pytest.mark.parametrize( - "notebook_file", - [ - 'using_a_script_languages_container.ipynb', - ] -) + conf.save(CKey.slc_source, slc_source) + conf.save(CKey.slc_target_dir, str(_slc_repo_dir())) + + +@pytest.fixture() +def cleanup_slc_repo_dir(): + import shutil + yield + p = Path.cwd() / "script_languages_container" / "script_languages_release" + shutil.rmtree(p) + + @pytest.mark.parametrize('access_to_temp_secret_store', [StorageBackend.onprem], indirect=True) -def test_script_languages_container(access_to_temp_secret_store, uploading_hack, notebook_file) -> None: - current_dir = os.getcwd() +def test_script_languages_container_cloning_slc_repo(access_to_temp_secret_store, + cleanup_slc_repo_dir) -> None: + current_dir = Path.cwd() store_path, store_password = access_to_temp_secret_store store_file = str(store_path) try: + run_notebook('main_config.ipynb', store_file, store_password) + os.chdir('./script_languages_container') + _store_slc_config(store_path, store_password, True) + run_notebook('configure_slc_flavor.ipynb', store_file, store_password) + run_notebook('using_a_script_languages_container.ipynb', store_file, store_password) + finally: + os.chdir(current_dir) + + +def _clone_slc_repo(): + from git import Repo + repo = Repo.clone_from("https://github.com/exasol/script-languages-release", _slc_repo_dir()) + repo.submodule_update(recursive=True) + +@pytest.mark.parametrize('access_to_temp_secret_store', [StorageBackend.onprem], indirect=True) +def test_script_languages_container_with_existing_slc_repo(access_to_temp_secret_store, + cleanup_slc_repo_dir) -> None: + current_dir = Path.cwd() + store_path, store_password = access_to_temp_secret_store + store_file = str(store_path) + try: run_notebook('main_config.ipynb', store_file, store_password) os.chdir('./script_languages_container') + slc_repo_path = _slc_repo_dir() + assert not slc_repo_path.is_dir() + _clone_slc_repo() + _store_slc_config(store_path, store_password, False) run_notebook('configure_slc_flavor.ipynb', store_file, store_password) - run_notebook('using_a_script_language_container.ipynb', store_file, store_password) + run_notebook('using_a_script_languages_container.ipynb', store_file, store_password) finally: os.chdir(current_dir)