Skip to content

Commit 63cd431

Browse files
committed
For consistency implement -r on shed_create, add tests.
1 parent 59b4357 commit 63cd431

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

planemo/commands/cmd_shed_create.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,30 @@
2222
@options.shed_key_option()
2323
@options.shed_email_option()
2424
@options.shed_password_option()
25+
@options.recursive_shed_option()
2526
@pass_context
2627
def cli(ctx, path, **kwds):
2728
"""Create a repository in the toolshed from a .shed.yml file
2829
"""
2930
tsi = shed.tool_shed_client(ctx, **kwds)
30-
repo_id = __find_repository(ctx, tsi, path, **kwds)
31-
if repo_id is None:
32-
if __create_repository(ctx, tsi, path, **kwds):
33-
info("Repository created")
31+
32+
def create(path):
33+
repo_id = __find_repository(ctx, tsi, path, **kwds)
34+
if repo_id is None:
35+
if __create_repository(ctx, tsi, path, **kwds):
36+
info("Repository created")
37+
return 0
38+
else:
39+
return 2
3440
else:
35-
sys.exit(2)
41+
return 1
42+
43+
if kwds['recursive']:
44+
exit_code = shed.for_each_repository(create, path)
3645
else:
37-
sys.exit(1)
46+
exit_code = create(path)
47+
48+
sys.exit(exit_code)
3849

3950

4051
def __find_repository(ctx, tsi, path, **kwds):

tests/test_shed_create.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from .test_utils import CliShedTestCase
2+
3+
4+
class ShedCreateTestCase(CliShedTestCase):
5+
6+
def test_create_single(self):
7+
with self._isolate_repo("single_tool"):
8+
create_command = ["shed_create"]
9+
create_command.extend(self._shed_args())
10+
self._check_exit_code(create_command)
11+
12+
def test_create_multiple(self):
13+
with self._isolate_repo("multi_repos_nested"):
14+
create_command = ["shed_create", "-r"]
15+
create_command.extend(self._shed_args())
16+
self._check_exit_code(create_command)

0 commit comments

Comments
 (0)