Skip to content

Commit

Permalink
Merge pull request #1350 from lldelisle/make_test_run
Browse files Browse the repository at this point in the history
Make test dockstore init with creator run and pass
  • Loading branch information
mvdbeek committed Feb 16, 2023
2 parents da2c58b + 7cc16d3 commit ef68fb3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion planemo/workflow_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def generate_dockstore_yaml(directory: str, publish: bool = True) -> str:
requests.get(
f"https://orcid.org/{orcid[0]}",
headers={"Accept": "application/xml"},
allow_redirects=False,
allow_redirects=True,
).status_code
== 200
):
Expand Down
13 changes: 9 additions & 4 deletions tests/test_cmd_dockstore_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def test_init_publish_true(self):
def test_init_publish_false(self):
self.run_dockstore_init(False)

def test_init_with_creator(self):
self.run_dockstore_init_with_creator()

def run_dockstore_init(self, publish: Optional[bool] = None):
with self._isolate_with_test_data("wf_repos/from_format2/0_basic_native") as f:
init_cmd = ["dockstore_init"]
Expand All @@ -38,15 +41,17 @@ def run_dockstore_init(self, publish: Optional[bool] = None):
self._check_exit_code(workflow_lint_cmd)

def run_dockstore_init_with_creator(self):
with self._isolate_with_test_data("wf_repos/autoupdate_tests/workflow_with_unexisting_version_of_tool.ga") as f:
init_cmd = ["dockstore_init", f]
with self._isolate_workflow("wf_repos/autoupdate_tests/workflow_with_unexisting_tool.ga") as f:
init_cmd = ["dockstore_init"]
self._check_exit_code(init_cmd)
assert os.path.exists(".dockstore.yml")
with open(".dockstore.yml") as fh:
dockstore_config = yaml.safe_load(fh)
assert str(dockstore_config["version"]) == "1.2"
assert "workflows" in dockstore_config
assert len(dockstore_config["workflows"]) == 1
assert "authors" in dockstore_config["workflows"]
assert dockstore_config["workflows"]["authors"]["orcid"] == "0000-0002-1964-4960"
workflow = dockstore_config["workflows"][0]
assert "authors" in workflow
assert workflow["authors"][0]["orcid"] == "0000-0002-1964-4960"
workflow_lint_cmd = ["workflow_lint", "--skip", "tool_ids", "--fail_level", "error", f]
self._check_exit_code(workflow_lint_cmd)
10 changes: 10 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ def _isolate_repo(self, name):
self._copy_repo(name, f)
yield f

@contextlib.contextmanager
def _isolate_workflow(self, name):
with self._isolate() as f:
self._copy_workflow(name, f)
yield f

@contextlib.contextmanager
def _isolate_with_test_data(self, relative_path):
with self._isolate() as f:
Expand All @@ -126,6 +132,10 @@ def _copy_repo(self, name, dest):
repo = os.path.join(TEST_REPOS_DIR, name)
self._copy_directory(repo, dest)

def _copy_workflow(self, name, dest):
workflow = os.path.join(TEST_DATA_DIR, name)
io.shell(["cp", workflow, dest])

def _copy_directory(self, path, dest):
io.shell(["cp", "-r", f"{path}/.", dest])

Expand Down

0 comments on commit ef68fb3

Please sign in to comment.