Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
cduriau committed Feb 17, 2024
1 parent 2946736 commit 489f320
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Empty file added tests/data/scripts/foo
Empty file.
Empty file added tests/data/scripts/foo-0.1.0
Empty file.
16 changes: 16 additions & 0 deletions tests/test_scriptutils.py
Original file line number Diff line number Diff line change
@@ -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"),
]

0 comments on commit 489f320

Please sign in to comment.