Skip to content

Commit

Permalink
move http_specs to class attribute; fix typo; fix bokeh test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg1969 committed Jan 5, 2019
1 parent e5c3644 commit fcda73e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
5 changes: 2 additions & 3 deletions anaconda_project/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"""Plugins base classes and functions."""
import os
from os.path import join
from anaconda_project.project_commands import (_ArgsTransformer, ProjectCommand, _http_specs)
from anaconda_project.project_commands import (_ArgsTransformer, ProjectCommand)


class ArgsTrasformerTemplate(_ArgsTransformer):
class ArgsTransformerTemplate(_ArgsTransformer):
"""Template class for plugins args trasformers.
Plugins args transformers should subclass it and redefine add_class
Expand All @@ -24,7 +24,6 @@ def __init__(self, command):
Args:
command (ProjectCommand): command that maps to the ArgsTransformer
"""
super(ArgsTrasformerTemplate, self).__init__(_http_specs)
self.command = command

def add_args(self, results, args):
Expand Down
12 changes: 6 additions & 6 deletions anaconda_project/project_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ def _is_windows():

_ArgSpec = namedtuple('_ArgSpec', ['option', 'has_value'])

_http_specs = (_ArgSpec('--anaconda-project-host', True), _ArgSpec('--anaconda-project-address', True),
_ArgSpec('--anaconda-project-port', True), _ArgSpec('--anaconda-project-url-prefix', True),
_ArgSpec('--anaconda-project-no-browser', False), _ArgSpec('--anaconda-project-iframe-hosts', True),
_ArgSpec('--anaconda-project-use-xheaders', False))
HTTP_SPECS = (_ArgSpec('--anaconda-project-host', True), _ArgSpec('--anaconda-project-address', True),
_ArgSpec('--anaconda-project-port', True), _ArgSpec('--anaconda-project-url-prefix', True),
_ArgSpec('--anaconda-project-no-browser', False), _ArgSpec('--anaconda-project-iframe-hosts', True),
_ArgSpec('--anaconda-project-use-xheaders', False))


class _ArgsTransformer(object):
specs = _http_specs
specs = HTTP_SPECS

def _parse_args_removing_known(self, results, args):
if not args:
Expand Down Expand Up @@ -281,7 +281,7 @@ def execvpe(self):


def _append_extra_args_to_command_line(command, extra_args):
if extra_args is None:
if not extra_args:
return command
else:
if _is_windows(): # pragma: no cover
Expand Down
4 changes: 2 additions & 2 deletions anaconda_project/test/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from anaconda_project.project_file import DEFAULT_PROJECT_FILENAME
from anaconda_project import project

from anaconda_project.plugins import CommandTemplate, ArgsTrasformerTemplate
from anaconda_project.plugins import CommandTemplate, ArgsTransformerTemplate


def test_prepare_plugin_command(monkeypatch, tmpdir):
Expand All @@ -26,7 +26,7 @@ def test_prepare_plugin_command(monkeypatch, tmpdir):
def get_plugins_mock(cmd_type):
return {'valid_package_plugin': plugin_init_mock}

class TestTransformer(ArgsTrasformerTemplate):
class TestTransformer(ArgsTransformerTemplate):
def add_args(self, results, args):
return ['--show']

Expand Down
12 changes: 2 additions & 10 deletions anaconda_project/test/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,10 +1495,7 @@ def check(dirname):
])
path = os.pathsep.join([environ['PROJECT_DIR'], environ['PATH']])
jupyter_notebook = _assert_find_executable('jupyter-notebook', path)
assert cmd_exec.args == [
jupyter_notebook,
os.path.join(dirname, 'test.ipynb'), 'foo', 'bar'
]
assert cmd_exec.args == [jupyter_notebook, os.path.join(dirname, 'test.ipynb'), 'foo', 'bar']
assert cmd_exec.shell is False

with_directory_contents_completing_project_file({
Expand Down Expand Up @@ -2013,12 +2010,7 @@ def check(dirname):
])
path = os.pathsep.join([environ['PROJECT_DIR'], environ['PATH']])
bokeh = _assert_find_executable('bokeh', path)
assert cmd_exec.args == [
bokeh, 'serve',
os.path.join(dirname, 'test.py'), '--foo', '--anaconda-project-url-prefix', 'blah',
'--anaconda-project-port', '1234', '--anaconda-project-host', 'example.com',
'--anaconda-project-no-browser', '--anaconda-project-use-xheaders'
]
assert cmd_exec.args == [bokeh, 'serve', os.path.join(dirname, 'test.py'), '--foo']
assert cmd_exec.shell is False

with_directory_contents_completing_project_file(
Expand Down

0 comments on commit fcda73e

Please sign in to comment.