diff --git a/tests/conftest.py b/tests/conftest.py index 6a3d0f1..eaa9fd5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -43,6 +43,12 @@ def fix_dir_installed(fix_test_data: str): return path +@pytest.fixture +def fix_dir_scripts(fix_test_data: str): + path = os.path.join(fix_test_data, "scripts") + return path + + @pytest.fixture def fix_file_config_tmp(monkeypatch: pytest.MonkeyPatch) -> None: _, tmp_config = tempfile.mkstemp(suffix=".json", prefix="software") @@ -70,3 +76,8 @@ def mock_settings_dir_download(fix_dir_downloaded: str, monkeypatch: pytest.Monk @pytest.fixture def mock_settings_dir_install(fix_dir_installed: str, monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr(settings, "DIR_INSTALL", fix_dir_installed) + + +@pytest.fixture +def mock_settings_dir_scripts(fix_dir_scripts: str, monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr(settings, "DIR_SCRIPTS", fix_dir_scripts) diff --git a/tests/data/scripts/foo b/tests/data/scripts/foo new file mode 100644 index 0000000..e69de29 diff --git a/tests/data/scripts/foo-0.1.0 b/tests/data/scripts/foo-0.1.0 new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_scriptutils.py b/tests/test_scriptutils.py new file mode 100644 index 0000000..838729b --- /dev/null +++ b/tests/test_scriptutils.py @@ -0,0 +1,16 @@ +# stdlib +import os + +# package +from packagerbuddy import scriptutils + + +def test_find_scripts( + mock_settings_dir_scripts: None, + fix_dir_scripts: str, +) -> None: + scripts = scriptutils.find_scripts("foo", "0.1.0") + assert scripts == [ + os.path.join(fix_dir_scripts, "foo"), + os.path.join(fix_dir_scripts, "foo-0.1.0"), + ]