Skip to content

Commit

Permalink
test: add new workflow repo fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
ilveroluca committed Jun 13, 2023
1 parent 552caab commit 2bee5c4
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 30 deletions.
18 changes: 10 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ instance
**/__pycache__
**/.npm
*.pyc
./certs
/certs
**/node_modules
backups
data
lifemonitor/static/dist
lifemonitor/static/src/node_modules
docker-compose.yml
#data
/lifemonitor/static/dist
/lifemonitor/static/src/node_modules
/docker-compose.yml
.*docker-compose.yml
utils/certs/data
tests/config/data/crates/*.zip
tests/config/registries/seek/data
/utils/certs/data
/tests/config/registries/seek/data
/tests/config/data/ro-crate*.zip
/tests/config/data/crates/
/interaction_experiments/_OLD_TEST_METADATA/data
2 changes: 1 addition & 1 deletion settings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ MAIL_USE_SSL=True
MAIL_DEFAULT_SENDER=''

# Storage path of workflow RO-Crates
# DATA_WORKFLOWS = "./data"
DATA_WORKFLOWS = "/var/data/lm"

# Cache settings
CACHE_REDIS_DB=0
Expand Down
2 changes: 1 addition & 1 deletion tests/config/data/make-test-rocrates.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
logger.debug("RO-CRATES SOURCE PATH: %s", crates_source_path)

crates_target_path = os.path.join(current_path, "crates")
logger.debug("RO-CRATES SOURCE PATH: %s", crates_target_path)
logger.debug("RO-CRATES TARGET PATH: %s", crates_target_path)

# List of RO-Crates to be created.
# New RO-crates are created by copying a path under crates_source_path to a path under crates_target_path.
Expand Down
1 change: 1 addition & 0 deletions tests/config/data/repos/test-galaxy-wf-repo
Submodule test-galaxy-wf-repo added at eb9d46
39 changes: 34 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import re
import shutil
import string
import tempfile
import uuid
from collections.abc import Iterable
from pathlib import Path
Expand Down Expand Up @@ -71,16 +72,21 @@
os.environ.pop("FLASK_APP_CONFIG_FILE", None)


@pytest.fixture
def current_path():
return os.path.dirname(os.path.abspath(__file__))


@pytest.fixture
def headers():
return helpers.get_headers()


@pytest.fixture(scope='session')
def test_repo_collection_path() -> Path:
return Path(__file__).parent / 'config' / 'data' / 'repos'


@pytest.fixture(scope='session')
def test_crate_collection_path() -> Path:
return Path(__file__).parent / 'config' / 'data' / 'crates'


@pytest.fixture
def lm() -> LifeMonitor:
return LifeMonitor.get_instance()
Expand Down Expand Up @@ -490,3 +496,26 @@ def repository() -> Generator[LocalWorkflowRepository, None, None]:
yield repo
finally:
repo.cleanup()


@pytest.fixture
def github_repository() -> GithubWorkflowRepository:
repo = GithubWorkflowRepository('iwc-workflows/gromacs-mmgbsa', ref="HEAD")
logger.debug("Github workflow repository: %r", repo)
return repo

@pytest.fixture
def simple_local_wf_repo(test_repo_collection_path: Path) -> Generator[LocalGitWorkflowRepository, None, None]:
"""
On-disk git repository with a dummy Galaxy workflow. Should follow best practices.
"""
source_repo_path = test_repo_collection_path / 'test-galaxy-wf-repo'

# make a temporary copy of the source repository so that tests can freely
# modify it.
with tempfile.TemporaryDirectory(prefix=f"tmp-{source_repo_path.name}") as tmpdir:
tmp_repo_path = shutil.copytree(source_repo_path,
Path(tmpdir) / source_repo_path.name,
symlinks=True)
repo = LocalGitWorkflowRepository(str(tmp_repo_path))
yield repo
23 changes: 8 additions & 15 deletions tests/unit/issues/test_rocrate_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,34 @@
logger = logging.getLogger(__name__)


@pytest.fixture
def repository() -> GithubWorkflowRepository:
repo = GithubWorkflowRepository('iwc-workflows/gromacs-mmgbsa', ref="HEAD")
logger.debug("Github workflow repository: %r", repo)
return repo


@pytest.fixture
def issue() -> MissingROCrateFile:
return MissingROCrateFile()


def test_check_true(repository: GithubWorkflowRepository, issue: MissingROCrateFile):
logger.debug("Workflow RO-Crate: %r", repository)
def test_check_true(github_repository: GithubWorkflowRepository, issue: MissingROCrateFile):
logger.debug("Workflow RO-Crate: %r", github_repository)

# detect workflow metadata
metadata = repository.metadata
metadata = github_repository.metadata
logger.debug("Detected workflow metadata: %r", metadata)
assert metadata, "Workflow metadata not found"

# test if issue doesn't apply to the current repo
result = issue.check(repository)
result = issue.check(github_repository)
assert result is False, "Workflow RO-Crate should have the workflow file"


def test_check_false(repository: GithubWorkflowRepository, issue: MissingROCrateFile):
logger.debug("Workflow RO-Crate: %r", repository)
def test_check_false(github_repository: GithubWorkflowRepository, issue: MissingROCrateFile):
logger.debug("Workflow RO-Crate: %r", github_repository)

# detect workflow file
metadata = repository.metadata
metadata = github_repository.metadata
logger.debug("Detected workflow file: %r", metadata)
assert metadata, "Workflow file not found"

# set reference to local copy of the remote repo
local = repository.local_repo
local = github_repository.local_repo

# temporary remove workflow metadata from the local repo
local.remove_file(metadata.repository_file)
Expand Down

0 comments on commit 2bee5c4

Please sign in to comment.