Skip to content

Commit fb518ba

Browse files
committed
finish skipped tests in test_root_compiler
1 parent 8904fd3 commit fb518ba

2 files changed

Lines changed: 29 additions & 7 deletions

File tree

‎paths_cli/compiling/root_compiler.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def _proxy(self):
108108
def named_objs(self):
109109
return self._proxy.named_objs
110110

111-
def __call__(self, *args, **kwargs):
112-
return self._proxy(*args, **kwargs)
111+
def __call__(self, dct):
112+
return self._proxy(dct)
113113

114114
def compiler_for(category):
115115
"""Delayed compiler calling.

‎paths_cli/tests/compiling/test_root_compiler.py‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
_register_builder_plugin, _register_compiler_plugin,
77
_sort_user_categories, _CategoryCompilerProxy, _COMPILERS, _ALIASES
88
)
9+
from paths_cli.tests.compiling.utils import mock_compiler
910
from unittest.mock import Mock, PropertyMock, patch
1011
from paths_cli.compiling.core import (
1112
CategoryCompiler, InstanceCompilerPlugin
@@ -21,7 +22,7 @@ def foo_compiler():
2122

2223
@pytest.fixture
2324
def foo_compiler_plugin():
24-
return CategoryPlugin(Mock(category='foo'), ['bar'])
25+
return CategoryPlugin(Mock(category='foo', __name__='foo'), ['bar'])
2526

2627
@pytest.fixture
2728
def foo_baz_builder_plugin():
@@ -73,7 +74,17 @@ def test_named_objs(self):
7374

7475
def test_call(self):
7576
# the `__call__` method should work in the proxy
76-
pytest.skip()
77+
def _bar_dispatch(dct):
78+
return dct['baz'] * dct['qux']
79+
80+
foo_compiler = mock_compiler(
81+
category='foo',
82+
type_dispatch={'bar': _bar_dispatch},
83+
)
84+
proxy = _CategoryCompilerProxy('foo')
85+
user_input = {'type': 'bar', 'baz': 'baz', 'qux': 2}
86+
with patch.dict(COMPILER_LOC, {'foo': foo_compiler}):
87+
assert proxy(user_input) == "bazbaz"
7788

7889
def test_compiler_for_nonexisting():
7990
# if nothing is ever registered with the compiler, then compiler_for
@@ -141,7 +152,9 @@ def test_get_registration_names(canonical, aliases, expected):
141152
def test_register_compiler_plugin(foo_compiler_plugin):
142153
# _register_compiler_plugin should register compilers that don't exist
143154
compilers = {}
144-
with patch.dict(COMPILER_LOC, compilers):
155+
aliases = {}
156+
with patch.dict(COMPILER_LOC, compilers) as _compiler, \
157+
patch.dict(BASE + "_ALIASES", aliases) as _alias:
145158
assert 'foo' not in compilers
146159
_register_compiler_plugin(foo_compiler_plugin)
147160
assert 'foo' in _COMPILERS
@@ -199,9 +212,18 @@ def test_register_plugins_unit(foo_compiler_plugin, foo_baz_builder_plugin):
199212
assert builder.called_once_with(foo_baz_builder_plugin)
200213
assert compiler.called_once_with(foo_compiler_plugin)
201214

202-
def test_register_plugins_integration():
215+
def test_register_plugins_integration(foo_compiler_plugin,
216+
foo_baz_builder_plugin):
203217
# register_plugins should correctly register plugins
204-
pytest.skip()
218+
compilers = {}
219+
aliases = {}
220+
with patch.dict(COMPILER_LOC, compilers) as _compiler, \
221+
patch.dict(BASE + "_ALIASES", aliases) as _alias:
222+
assert 'foo' not in _COMPILERS
223+
register_plugins([foo_compiler_plugin, foo_baz_builder_plugin])
224+
assert 'foo' in _COMPILERS
225+
type_dispatch = _COMPILERS['foo'].type_dispatch
226+
assert type_dispatch['baz'] is foo_baz_builder_plugin
205227

206228
def test_sort_user_categories():
207229
# sorted user categories should match the expected compile order

0 commit comments

Comments
 (0)