unit test to make sure all generated help can be parsed by docopt

This commit is contained in:
Lex Berezhny 2020-09-04 10:57:11 -04:00
parent b4ee07162d
commit 33e266a0f4

View file

@ -1,6 +1,9 @@
from unittest import TestCase
from unittest import TestCase, mock
from textwrap import dedent
from lbry.service.api import Paginated, Wallet, expander
from docopt import docopt, DocoptExit
from lbry.service.api import API, Paginated, Wallet, expander
from lbry.service.parser import (
parse_method, get_expanders, get_api_definitions,
generate_options
@ -194,6 +197,14 @@ class TestParser(TestCase):
class TestGenerator(TestCase):
maxDiff = None
def test_generated_api_works_in_docopt(self):
from lbry.service.metadata import interface
for command in interface["commands"].values():
with mock.patch('sys.exit') as exit:
with self.assertRaises(DocoptExit):
docopt(command["help"], ["--help"])
self.assertTrue(exit.called)
def test_generate_options(self):
expanders = get_expanders()
self.assertEqual(