예제 #1
0
 def test_list(self):
     ref_input = {'arch': ['x86_64', 'i386']}
     output = python_utils.reverse_argparse(ref_input)
     assert len(output) == 4
     assert output[0] == '--arch'
     assert output[2] == '--arch'
     assert 'x86_64' in output
     assert 'i386' in output
예제 #2
0
 def test_complex(self):
     ref_input = {
         'item': 'foo',
         'debug': True,
         'arch': ['x86_64', 'i386'],
         'job_id': 1234,
         't': 'koji',
         'override': ['foo=bar'],
         'ignore_me': True
     }
     ref_ignore = ['ignore_me', 'extra_ignore']
     ref_output = [
         '--item', 'foo', '--debug', '--arch', 'x86_64', '--arch', 'i386',
         '--job-id', '1234', '-t', 'koji', '--override', 'foo=bar'
     ]
     output = python_utils.reverse_argparse(ref_input, ignore=ref_ignore)
     assert sorted(ref_output) == sorted(output)
     assert output.index('--item') == output.index('foo') - 1
     assert output.index('--job-id') == output.index('1234') - 1
     assert output.index('-t') == output.index('koji') - 1
     assert output.index('--override') == output.index('foo=bar') - 1
예제 #3
0
 def test_short_option(self):
     ref_input = {'i': 'foo'}
     output = python_utils.reverse_argparse(ref_input)
     assert output == ['-i', 'foo']
예제 #4
0
 def test_long_option(self):
     ref_input = {'item': 'foo'}
     output = python_utils.reverse_argparse(ref_input)
     assert output == ['--item', 'foo']
예제 #5
0
 def test_no_input(self):
     ref_input = {}
     output = python_utils.reverse_argparse(ref_input)
     assert output == []
예제 #6
0
 def test_ignore_underscore(self):
     ref_input = {'job_id': 1234}
     output = python_utils.reverse_argparse(ref_input, ignore=('job_id'))
     assert output == []
     output = python_utils.reverse_argparse(ref_input, ignore=('job-id'))
     assert output == ['--job-id', '1234']
예제 #7
0
 def test_multiple_ignore(self):
     ref_input = {'item': 'foo', 'type': 'koji_tag'}
     output = python_utils.reverse_argparse(ref_input,
                                            ignore=('item', 'type'))
     assert output == []
예제 #8
0
 def test_ignore_more_options(self):
     ref_input = {'item': 'foo', 'type': 'koji_tag'}
     output = python_utils.reverse_argparse(ref_input, ignore=('item'))
     assert output == ['--type', 'koji_tag']
예제 #9
0
 def test_ignore(self):
     ref_input = {'item': 'foo'}
     output = python_utils.reverse_argparse(ref_input, ignore=('item'))
     assert output == []
예제 #10
0
 def test_underscore_to_dash(self):
     ref_input = {'job_id': 1234}
     output = python_utils.reverse_argparse(ref_input)
     assert output == ['--job-id', '1234']
예제 #11
0
 def test_number(self):
     ref_input = {'count': 1234}
     output = python_utils.reverse_argparse(ref_input)
     assert output == ['--count', '1234']
예제 #12
0
 def test_none(self):
     ref_input = {'item': None}
     output = python_utils.reverse_argparse(ref_input)
     assert output == []
예제 #13
0
 def test_boolean_false(self):
     ref_input = {'debug': False}
     output = python_utils.reverse_argparse(ref_input)
     assert output == []
예제 #14
0
 def test_boolean(self):
     ref_input = {'debug': True}
     output = python_utils.reverse_argparse(ref_input)
     assert output == ['--debug']