Skip to content

Commit f7d923a

Browse files
committed
fully remove old OPSPlugin from tests
1 parent e9a9b59 commit f7d923a

3 files changed

Lines changed: 30 additions & 26 deletions

File tree

‎paths_cli/plugin_management.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
import importlib
44
import os
55

6-
# TODO: this should be removed
7-
OPSPlugin = collections.namedtuple(
8-
"OPSPlugin", ['name', 'location', 'func', 'section', 'plugin_type']
9-
)
10-
116
class PluginRegistrationError(RuntimeError):
127
pass
138

‎paths_cli/tests/null_command.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import click
33

4-
from paths_cli.plugin_management import FilePluginLoader, OPSPlugin
4+
from paths_cli.plugin_management import FilePluginLoader, OPSCommandPlugin
55

66
@click.command(
77
'null-command',
@@ -11,17 +11,17 @@ def null_command():
1111
logger = logging.getLogger(__name__)
1212
logger.info("Running null command")
1313

14-
CLI = null_command
15-
SECTION = "Workflow"
14+
PLUGIN = OPSCommandPlugin(
15+
command=null_command,
16+
section="Workflow"
17+
)
1618

1719
class NullCommandContext(object):
1820
"""Context that registers/deregisters the null command (for tests)"""
1921
def __init__(self, cli):
20-
self.plugin = OPSPlugin(name="null-command",
21-
location=__file__,
22-
func=CLI,
23-
section=SECTION,
24-
plugin_type="file")
22+
self.plugin = PLUGIN
23+
self.plugin.attach_metadata(location=__file__,
24+
plugin_type='file')
2525

2626
cli._register_plugin(self.plugin)
2727
self.cli = cli

‎paths_cli/tests/test_cli.py‎

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,40 @@
33
from click.testing import CliRunner
44

55
from paths_cli.cli import *
6-
from paths_cli.plugin_management import OPSPlugin
6+
# from paths_cli.plugin_management import OPSPlugin
77
from .null_command import NullCommandContext
88

99

1010
class TestOpenPathSamplingCLI(object):
1111
def setup(self):
12-
def make_mock(name, helpless=False):
13-
mock = MagicMock(return_value=name)
12+
def make_mock(name, helpless=False, return_val=None):
13+
if return_val is None:
14+
return_val = name
15+
mock = MagicMock(return_value=return_val)
16+
mock.name = name
1417
if helpless:
1518
mock.short_help = None
1619
else:
1720
mock.short_help = name + " help"
1821
return mock
1922

23+
foo_plugin = OPSCommandPlugin(
24+
command=make_mock('foo'),
25+
section="Simulation"
26+
)
27+
foo_plugin.attach_metadata(location="foo.py",
28+
plugin_type='file')
29+
foobar_plugin = OPSCommandPlugin(
30+
command=make_mock('foo-bar', helpless=True,
31+
return_val='foobar'),
32+
section="Miscellaneous"
33+
)
34+
foobar_plugin.attach_metadata(location='foo_bar.py',
35+
plugin_type='file')
36+
2037
self.plugin_dict = {
21-
'foo': OPSPlugin(name='foo',
22-
location='foo.py',
23-
func=make_mock('foo'),
24-
section='Simulation',
25-
plugin_type='file'),
26-
'foo-bar': OPSPlugin(name='foo-bar',
27-
location='foo_bar.py',
28-
func=make_mock('foobar', helpless=True),
29-
section='Miscellaneous',
30-
plugin_type="file")
38+
'foo': foo_plugin,
39+
'foo-bar': foobar_plugin,
3140
}
3241
self.plugins = list(self.plugin_dict.values())
3342
self.cli = OpenPathSamplingCLI()

0 commit comments

Comments
 (0)