Files
openfe/openfecli/tests/test_fetchables.py
2025-12-04 00:07:48 +00:00

34 lines
1.1 KiB
Python

import pathlib
import pytest
from click.testing import CliRunner
from openfecli.fetchables import RBFE_TUTORIAL, RBFE_TUTORIAL_RESULTS
from openfecli.fetching import FetchablePlugin
from .conftest import HAS_INTERNET
def fetchable_test(fetchable):
"""Unit test to ensure that a given FetchablePlugin works"""
assert isinstance(fetchable, FetchablePlugin)
expected_paths = [pathlib.Path(f) for f in fetchable.filenames]
runner = CliRunner()
if fetchable.fetcher.REQUIRES_INTERNET and not HAS_INTERNET: # -no-cov-
pytest.skip("Internet seems to be unavailable")
with runner.isolated_filesystem():
result = runner.invoke(fetchable.command, ["-doutput-dir"])
assert result.exit_code == 0
for path in expected_paths:
assert (pathlib.Path("output-dir") / path).exists()
@pytest.mark.flaky(reruns=3) # in case of Too Many Request error
def test_rbfe_tutorial():
fetchable_test(RBFE_TUTORIAL)
@pytest.mark.flaky(reruns=3) # in case of Too Many Request error
def test_rbfe_tutorial_results():
fetchable_test(RBFE_TUTORIAL_RESULTS)