|
|
@ -155,6 +155,26 @@ class TestArgparse(unittest.TestCase): |
|
|
|
self.assertEqual(getin(item, ['data', 'default']), None) |
|
|
|
|
|
|
|
|
|
|
|
def test_version_maps_to_checkbox(self): |
|
|
|
testcases = [ |
|
|
|
[['--version'], {}, 'TextField'], |
|
|
|
# we only remap if the action is version |
|
|
|
# i.e. we don't care about the argument name itself |
|
|
|
[['--version'], {'action': 'store'}, 'TextField'], |
|
|
|
# should get mapped to CheckBox becuase of the action |
|
|
|
[['--version'], {'action': 'version'}, 'CheckBox'], |
|
|
|
# ditto, even through the 'name' isn't 'version' |
|
|
|
[['--foobar'], {'action': 'version'}, 'CheckBox'], |
|
|
|
] |
|
|
|
for args, kwargs, expectedType in testcases: |
|
|
|
with self.subTest([args, kwargs]): |
|
|
|
parser = argparse.ArgumentParser(prog='test') |
|
|
|
parser.add_argument(*args, **kwargs) |
|
|
|
result = argparse_to_json.convert(parser, num_required_cols=2, num_optional_cols=2) |
|
|
|
contents = getin(result, ['widgets', 'test', 'contents'])[0] |
|
|
|
self.assertEqual(contents['items'][0]['type'], expectedType) |
|
|
|
|
|
|
|
|
|
|
|
def test_textinput_with_list_default_mapped_to_cli_friendly_value(self): |
|
|
|
""" |
|
|
|
Issue: #500 |
|
|
|