Permalink
Browse files

For consistency implement -r on shed_create, add tests.

  • Loading branch information...
jmchilton committed Apr 24, 2015
1 parent 59b4357 commit 63cd43126fda0d6ed59913a66763770b6c2135b4
Showing with 33 additions and 6 deletions.
  1. +17 −6 planemo/commands/cmd_shed_create.py
  2. +16 −0 tests/test_shed_create.py
@@ -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):
@@ -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.