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

Fixing context when calling djangofy #30

Merged
merged 2 commits into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501: line too long (108 > 79 characters)

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501: line too long (104 > 79 characters)


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