Skip to content

Commit

Permalink
For consistency implement -r on shed_create, add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Apr 24, 2015
1 parent 59b4357 commit 63cd431
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
23 changes: 17 additions & 6 deletions planemo/commands/cmd_shed_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,30 @@
@options.shed_key_option()
@options.shed_email_option()
@options.shed_password_option()
@options.recursive_shed_option()
@pass_context
def cli(ctx, path, **kwds):
"""Create a repository in the toolshed from a .shed.yml file
"""
tsi = shed.tool_shed_client(ctx, **kwds)
repo_id = __find_repository(ctx, tsi, path, **kwds)
if repo_id is None:
if __create_repository(ctx, tsi, path, **kwds):
info("Repository created")

def create(path):
repo_id = __find_repository(ctx, tsi, path, **kwds)
if repo_id is None:
if __create_repository(ctx, tsi, path, **kwds):
info("Repository created")
return 0
else:
return 2
else:
sys.exit(2)
return 1

if kwds['recursive']:
exit_code = shed.for_each_repository(create, path)
else:
sys.exit(1)
exit_code = create(path)

sys.exit(exit_code)


def __find_repository(ctx, tsi, path, **kwds):
Expand Down
16 changes: 16 additions & 0 deletions tests/test_shed_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from .test_utils import CliShedTestCase


class ShedCreateTestCase(CliShedTestCase):

def test_create_single(self):
with self._isolate_repo("single_tool"):
create_command = ["shed_create"]
create_command.extend(self._shed_args())
self._check_exit_code(create_command)

def test_create_multiple(self):
with self._isolate_repo("multi_repos_nested"):
create_command = ["shed_create", "-r"]
create_command.extend(self._shed_args())
self._check_exit_code(create_command)

0 comments on commit 63cd431

Please sign in to comment.