Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #30 from cstrap/develop
Browse files Browse the repository at this point in the history
Fixing context when calling djangofy
  • Loading branch information
cstrap committed Oct 3, 2017
2 parents 7634726 + af1a6a3 commit ef3a0cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions python_vuejs/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ def djangofy(project):

@cli.command()
@click.argument('project')
def djstartvueapp(project):
@click.pass_context
def djstartvueapp(ctx, project):
"""
Run click commands on bash.
"""
click.echo(click.style('Creating {project}'.format(project=project), fg='green'))
if os.path.isfile('manage.py') and VueJsBuilder.startproject(project).status:
djangofy()
ctx.forward(djangofy)
ctx.invoke(djangofy, project=project)
else:
click.echo(click.style('Invalid django project directory', fg='red'))
4 changes: 4 additions & 0 deletions python_vuejs/vuejs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,23 @@ def install_cli():

@staticmethod
def project_setup(project):
click.echo(click.style('running `vue init webpack {project}`'.format(project=project), fg='yellow'))
run('vue init webpack {project}'.format(project=project).split())

@staticmethod
def install_dependencies(project):
with cd(project):
click.echo(click.style('running `npm install`', fg='yellow'))
run('npm install'.split())

@staticmethod
def dev():
click.echo(click.style('running `npm run dev`', fg='yellow'))
run('npm run dev'.split())

@staticmethod
def build():
click.echo(click.style('running `npm run build`', fg='yellow'))
run('npm run build'.split())


Expand Down
6 changes: 2 additions & 4 deletions tests/test_django_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ def test_djangofy_already_executed(self):
# Then
self.assertEqual('Making Vue.js myapp into django app\nCommand already executed\n', result.output)

@patch('python_vuejs.django.djangofy')
def test_djstartvueapp_django_ok(self, mock_djangofy):
def test_djstartvueapp_django_ok(self):
with self.runner.isolated_filesystem():
# Given
open('manage.py', 'a').close()
Expand All @@ -132,8 +131,7 @@ def test_djstartvueapp_django_ok(self, mock_djangofy):
result = self.runner.invoke(cli.cli, ['djstartvueapp', 'myapp'])
# Then
mock_vuejsbuilder.assert_called_once()
mock_djangofy.assert_called_once()
self.assertEqual('Creating myapp\n', result.output)
self.assertEqual('Creating myapp\nMaking Vue.js myapp into django app\n', result.output)

def test_djstartvueapp_django_ko(self):
result = self.runner.invoke(cli.cli, ['djstartvueapp', 'myapp'])
Expand Down

0 comments on commit ef3a0cd

Please sign in to comment.