Skip to content

Commit

Permalink
Two notebook tests:
Browse files Browse the repository at this point in the history
1. One which clones the slc-repo
2. The other one uses the existing repo
  • Loading branch information
tomuben committed Jul 12, 2024
1 parent 0278227 commit 4a92697
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
61 changes: 47 additions & 14 deletions test/notebooks/nbtest_script_languages_container.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import textwrap
from pathlib import Path

import pytest
Expand All @@ -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)

0 comments on commit 4a92697

Please sign in to comment.