forked from LBRYCommunity/lbry-sdk
raise instead of implicit deduplication of arguments
This commit is contained in:
parent
10ad4ed8d1
commit
c981c767b9
2 changed files with 22 additions and 20 deletions
|
@ -159,7 +159,7 @@ def parse_method(method, expanders: dict) -> dict:
|
|||
raise Exception(f"Expander '{expander_name}' not found, used by {d['name']}.")
|
||||
for expanded in expanders[expander_name]:
|
||||
if expanded['name'] in known_names:
|
||||
continue
|
||||
raise Exception(f"Expander '{expander_name}' argument repeated: {expanded['name']}.")
|
||||
d['arguments'].append(expanded)
|
||||
d['kwargs'].append(expanded)
|
||||
known_names.add(expanded['name'])
|
||||
|
|
|
@ -48,18 +48,6 @@ class FakeAPI:
|
|||
def thing_update(self, value1: str) -> Wallet: # updated wallet
|
||||
"""update command doc"""
|
||||
|
||||
def thing_search(
|
||||
self,
|
||||
query='a',
|
||||
**test_and_another_test_kwargs) -> Wallet:
|
||||
"""
|
||||
search command doc
|
||||
|
||||
Usage:
|
||||
thing search [--query=<query>]
|
||||
{kwargs}
|
||||
"""
|
||||
|
||||
def thing_delete(self, value1: str, **tx_and_pagination_kwargs) -> Wallet: # deleted thing
|
||||
"""
|
||||
delete command doc
|
||||
|
@ -84,13 +72,27 @@ class FakeAPI:
|
|||
"""
|
||||
|
||||
|
||||
class BadAPI(FakeAPI):
|
||||
def thing_search(
|
||||
self,
|
||||
query='a',
|
||||
**test_and_another_test_kwargs) -> Wallet:
|
||||
"""
|
||||
search command doc
|
||||
|
||||
Usage:
|
||||
thing search [--query=<query>]
|
||||
{kwargs}
|
||||
"""
|
||||
|
||||
|
||||
class TestParser(TestCase):
|
||||
maxDiff = None
|
||||
|
||||
def test_parse_does_not_duplicate_arguments(self):
|
||||
parsed = parse_method(FakeAPI.thing_search, get_expanders())
|
||||
names = [arg['name'] for arg in parsed['arguments']]
|
||||
self.assertEqual(len(names), len(set(names)))
|
||||
with self.assertRaises(Exception) as exc:
|
||||
parse_method(BadAPI.thing_search, get_expanders())
|
||||
self.assertEqual(exc.exception.args[0], "Expander 'another_test' argument repeated: thing_search.")
|
||||
|
||||
def test_parse_method(self):
|
||||
expanders = get_expanders()
|
||||
|
|
Loading…
Reference in a new issue