Skip to content

Commit 1cd4885

Browse files
committed
some root parser tests
1 parent 769d3f7 commit 1cd4885

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

‎paths_cli/tests/parsing/test_root_parser.py‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,39 @@
55
_register_parser_plugin
66
)
77
from unittest.mock import Mock, patch
8+
from paths_cli.parsing.core import Parser
89

910
PARSER_LOC = "paths_cli.parsing.root_parser.PARSERS"
1011

1112
class TestParserProxy:
1213
def setup(self):
14+
self.parser = Parser(None, "foo")
15+
self.parser.named_objs['bar'] = 'baz'
16+
self.proxy = ParserProxy('foo')
1317
pass
1418

1519
def test_proxy(self):
16-
# the _proxy should be the registered parser
17-
pytest.skip()
20+
# (NOT API) the _proxy should be the registered parser
21+
with patch.dict(PARSER_LOC, {'foo': self.parser}):
22+
assert self.proxy._proxy is self.parser
1823

1924
def test_proxy_nonexisting(self):
2025
# _proxy should error if the no parser is registered
21-
pytest.skip()
26+
with pytest.raises(KeyError):
27+
self.proxy._proxy
2228

2329
def test_named_objs(self):
2430
# the `.named_objs` attribute should work in the proxy
25-
pytest.skip()
31+
with patch.dict(PARSER_LOC, {'foo': self.parser}):
32+
assert self.proxy.named_objs == {'bar': 'baz'}
2633

2734
def test_call(self):
28-
# the `__call__` method should work in the proxy
2935
# the `__call__` method should work in the proxy
3036
pytest.skip()
3137

3238
def test_parser_for_nonexisting():
33-
# if the nothing is ever registered with the parser, then parser_for
34-
# should error
39+
# if nothing is ever registered with the parser, then parser_for should
40+
# error
3541
parsers = {}
3642
with patch.dict(PARSER_LOC, parsers):
3743
assert 'foo' not in parsers
@@ -43,7 +49,10 @@ def test_parser_for_nonexisting():
4349
def test_parser_for_existing():
4450
# if a parser already exists when parser_for is called, then parser_for
4551
# should get that as its proxy
46-
pytest.skip()
52+
foo_parser = Parser(None, 'foo')
53+
with patch.dict(PARSER_LOC, {'foo': foo_parser}):
54+
proxy = parser_for('foo')
55+
assert proxy._proxy is foo_parser
4756

4857
def test_parser_for_registered():
4958
# if a parser is registered after parser_for is called, then parser_for

0 commit comments

Comments
 (0)