Skip to content

Commit

Permalink
Fix test for situation where tests are ran outside a Github repo
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Feb 16, 2024
1 parent d783177 commit 291ca31
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

from hatch_openzim.metadata import update
from hatch_openzim.utils import DEFAULT_GITHUB_INFO


@pytest.fixture
Expand All @@ -17,6 +18,11 @@ def dynamic_metadata():
]


@pytest.fixture
def root_folder() -> Path:
return Path(os.path.dirname(os.path.abspath(__file__))).parent


@pytest.fixture
def metadata(dynamic_metadata):
return {
Expand All @@ -25,9 +31,13 @@ def metadata(dynamic_metadata):
}


def test_metadata_nominal(metadata):
def git_config_exists(root_folder: Path) -> bool:
return (root_folder / ".git/config").exists()


def test_metadata_nominal(metadata, root_folder):
update(
root=str(Path(os.path.dirname(os.path.abspath(__file__))).parent),
root=str(root_folder),
config={},
metadata=metadata,
)
Expand All @@ -43,7 +53,11 @@ def test_metadata_nominal(metadata):
assert metadata["license"] == {"text": "GPL-3.0-or-later"}
assert metadata["urls"] == {
"Donate": "https://www.kiwix.org/en/support-us/",
"Homepage": "https://github.com/openzim/hatch-openzim",
"Homepage": (
"https://github.com/openzim/hatch-openzim"
if git_config_exists(root_folder)
else DEFAULT_GITHUB_INFO.homepage
),
}


Expand Down

0 comments on commit 291ca31

Please sign in to comment.