Skip to content

Commit

Permalink
Fix -r/--recursive option when using shed_diff.
Browse files Browse the repository at this point in the history
Add test case for recursive shed_diff.

Closes #192.
  • Loading branch information
jmchilton committed May 8, 2015
1 parent 5f433be commit 3ee3ae8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
7 changes: 6 additions & 1 deletion planemo/shed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def _diff_in(ctx, working, realized_repository, **kwds):
realized_repository,
destination=other,
clean=True,
destination_is_pattern=False,
**kwds
)
if shed_target_source:
Expand All @@ -243,6 +244,7 @@ def _diff_in(ctx, working, realized_repository, **kwds):
realized_repository,
destination=mine,
clean=True,
destination_is_pattern=False,
**new_kwds
)
else:
Expand Down Expand Up @@ -472,7 +474,10 @@ def download_tarball(ctx, tsi, realized_repository, **kwds):
error(message)
raise Exception(message)
destination_pattern = kwds.get('destination', 'shed_download.tar.gz')
destination = realized_repository.pattern_to_file_name(destination_pattern)
if kwds.get("destination_is_pattern", True):
destination = realized_repository.pattern_to_file_name(destination_pattern)
else:
destination = destination_pattern
to_directory = not destination.endswith("gz")
download_tar(tsi, repo_id, destination, to_directory=to_directory)
if to_directory:
Expand Down
32 changes: 26 additions & 6 deletions tests/test_shed_diff.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
""" Integration tests for shed_diff command.
"""

import os
from os.path import join
from .test_utils import (
CliShedTestCase,
)
from planemo import io

DIFF_LINES = [
"diff -r _local_/related_file _custom_shed_/related_file",
Expand All @@ -13,19 +14,38 @@
]


class ShedUploadTestCase(CliShedTestCase):
class ShedDiffTestCase(CliShedTestCase):

def test_shed_diff(self):
with self._isolate_repo("single_tool") as f:
upload_command = ["shed_upload", "--force_repository_creation"]
upload_command.extend(self._shed_args())
self._check_exit_code(upload_command)
with open(os.path.join(f, "related_file"), "w") as r_f:
r_f.write("A related non-tool file (modified).\n")

io.write_file(
join(f, "related_file"),
"A related non-tool file (modified).\n",
)
self._check_diff(f, True)
self._check_diff(f, False)

def test_diff_recusrive(self):
with self._isolate_repo("multi_repos_nested") as f:
upload_command = [
"shed_upload", "-r", "--force_repository_creation"
]
upload_command.extend(self._shed_args())
self._check_exit_code(upload_command)

diff_command = ["shed_diff", "-r"]
diff_command.extend(self._shed_args(read_only=True))
self._check_exit_code(diff_command, exit_code=0)

io.write_file(
join(f, "cat1", "related_file"),
"A related non-tool file (modified).\n",
)
self._check_exit_code(diff_command, exit_code=-1)

def test_shed_diff_raw(self):
with self._isolate_repo("suite_auto"):
upload_command = [
Expand Down Expand Up @@ -53,7 +73,7 @@ def _check_diff(self, f, raw):
diff_command.append("--raw")
diff_command.extend(self._shed_args(read_only=True))
self._check_exit_code(diff_command, exit_code=-1)
diff_path = os.path.join(f, "diff")
diff_path = join(f, "diff")
with open(diff_path, "r") as diff_f:
diff = diff_f.read()
for diff_line in DIFF_LINES:
Expand Down

0 comments on commit 3ee3ae8

Please sign in to comment.