Skip to content

Commit

Permalink
Hook the scaffolder to the scaffold command.
Browse files Browse the repository at this point in the history
  • Loading branch information
mblayman committed Mar 6, 2016
1 parent 13367d3 commit 837149a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 3 additions & 2 deletions handroll/commands/scaffold.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ def register(self, subparsers):
parser.add_argument(
'scaffold', nargs='?', help=_('the scaffold to generate'))
parser.add_argument(
'site', nargs='?', help=_('the path to your website'))
'site', nargs='?', default='site',
help=_('the path to your website'))

def run(self, args):
if args.scaffold:
# scaffolder.make(args.scaffold, args.site)
scaffolder.make(args.scaffold, args.site)
finish()
else:
scaffolder.list_scaffolds()
19 changes: 18 additions & 1 deletion handroll/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import mock

from handroll.commands import Command
from handroll.commands.base import finish
from handroll.commands.build import BuildCommand
from handroll.commands.scaffold import ScaffoldCommand
from handroll.commands.watch import WatchCommand
Expand Down Expand Up @@ -38,6 +39,13 @@ def test_run_not_implemented(self):
command = Command()
self.assertRaises(NotImplementedError, command.run, args)

def test_finish(self):
try:
finish()
self.fail()
except SystemExit:
pass


class TestBuildCommand(TestCase):

Expand Down Expand Up @@ -114,7 +122,8 @@ def test_register_site(self):
subparsers.add_parser.return_value = parser
command = ScaffoldCommand()
command.register(subparsers)
site_call = (('site',), {'nargs': '?', 'help': mock.ANY})
site_call = (('site',), {
'nargs': '?', 'help': mock.ANY, 'default': 'site'})
self.assertIn(site_call, parser.add_argument.call_args_list)

@mock.patch('handroll.commands.scaffold.scaffolder.list_scaffolds')
Expand All @@ -123,3 +132,11 @@ def test_lists_scaffolds(self, list_scaffolds):
command = ScaffoldCommand()
command.run(args)
self.assertTrue(list_scaffolds.called)

@mock.patch('handroll.commands.scaffold.finish')
@mock.patch('handroll.commands.scaffold.scaffolder.make')
def test_complete_scaffold(self, make, finish):
args = mock.Mock(scaffold='default', site='site')
command = ScaffoldCommand()
command.run(args)
make.assert_called_once_with('default', 'site')

0 comments on commit 837149a

Please sign in to comment.