Skip to content

Commit b7d9e96

Browse files
committed
Bug fix for empty .shed.yml file and more testing.
1 parent d17bcaa commit b7d9e96

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

planemo/shed.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,14 @@ def shed_init(ctx, path, **kwds):
133133

134134
def shed_repo_config(path):
135135
shed_yaml_path = os.path.join(path, SHED_CONFIG_NAME)
136+
config = {}
136137
if os.path.exists(shed_yaml_path):
137138
with open(shed_yaml_path, "r") as f:
138-
return yaml.load(f)
139-
else:
140-
return {}
139+
config = yaml.load(f)
140+
141+
if config is None: # yaml may yield None
142+
config = {}
143+
return config
141144

142145

143146
def tool_shed_client(ctx=None, **kwds):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: cat1
2+
owner: iuc
3+
description: cat1 tool
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: cat2
2+
owner: iuc
3+
description: cat2 tool

tests/test_shed_upload.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from os.path import exists, join
55
import os
66
import tarfile
7+
import shutil
78

89
from .test_utils import CliShedTestCase
910

@@ -47,6 +48,16 @@ def test_cannont_recreate(self):
4748
self._check_exit_code(create_command)
4849
self._check_exit_code(create_command, exit_code=1)
4950

51+
def test_upload_recusrive(self):
52+
with self._isolate_repo("multi_repos_nested") as f:
53+
upload_command = [
54+
"shed_upload", "-r", "--force_repository_creation"
55+
]
56+
upload_command.extend(self._shed_args())
57+
self._check_exit_code(upload_command)
58+
self._verify_upload(f, ["cat1.xml", "macros.xml"], ["cat1"])
59+
self._verify_upload(f, ["cat2.xml", "macros.xml"], ["cat2"])
60+
5061
def test_upload_filters_invalid_suite(self):
5162
with self._isolate_repo("suite_1") as f:
5263
# No .shed.yml, make sure to test it can infer type
@@ -85,11 +96,16 @@ def test_upload_not_filters_unrestricted(self):
8596
assert exists(join(target, "README.rst"))
8697

8798
def _verify_single_uploaded(self, f):
88-
target = self._download_repo(f)
89-
assert exists(join(target, "cat.xml"))
99+
self._verify_upload(f, ["cat.xml"])
100+
101+
def _verify_upload(self, f, download_files=[], download_args=[]):
102+
target = self._download_repo(f, download_args)
103+
for download_file in download_files:
104+
assert exists(join(target, download_file))
90105

91-
def _download_repo(self, f):
106+
def _download_repo(self, f, download_args=[]):
92107
download_command = ["shed_download"]
108+
download_command.extend(download_args)
93109
download_command.extend(self._shed_args(read_only=True))
94110
self._check_exit_code(download_command)
95111
download = join(f, "shed_download.tar.gz")
@@ -98,6 +114,8 @@ def _download_repo(self, f):
98114

99115
def _untar(self, f, path):
100116
target = join(f, "download")
117+
if exists(target):
118+
shutil.rmtree(target)
101119
os.makedirs(target)
102120
tar = tarfile.open(path, "r:gz")
103121
tar.extractall(path=target)

tests/test_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" Provide abstractions over click testing of the
22
app and unittest.
33
"""
4+
from __future__ import print_function
45
import contextlib
56
import os
67
from tempfile import mkdtemp
@@ -91,6 +92,14 @@ def _shed_args(self, read_only=False):
9192
args.extend(["--shed_key", "ignored"])
9293
return args
9394

95+
def _print_shed_info(self):
96+
tsi = shed.tool_shed_client(
97+
None,
98+
shed_target=self.mock_shed.url,
99+
key="ignored",
100+
)
101+
print(tsi.repositories.get_repositories())
102+
94103

95104
@contextlib.contextmanager
96105
def mock_shed_client():

0 commit comments

Comments
 (0)