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
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
def test_short_option(self): ref_input = {'i': 'foo'} output = python_utils.reverse_argparse(ref_input) assert output == ['-i', 'foo']
def test_long_option(self): ref_input = {'item': 'foo'} output = python_utils.reverse_argparse(ref_input) assert output == ['--item', 'foo']
def test_no_input(self): ref_input = {} output = python_utils.reverse_argparse(ref_input) assert output == []
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']
def test_multiple_ignore(self): ref_input = {'item': 'foo', 'type': 'koji_tag'} output = python_utils.reverse_argparse(ref_input, ignore=('item', 'type')) assert output == []
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']
def test_ignore(self): ref_input = {'item': 'foo'} output = python_utils.reverse_argparse(ref_input, ignore=('item')) assert output == []
def test_underscore_to_dash(self): ref_input = {'job_id': 1234} output = python_utils.reverse_argparse(ref_input) assert output == ['--job-id', '1234']
def test_number(self): ref_input = {'count': 1234} output = python_utils.reverse_argparse(ref_input) assert output == ['--count', '1234']
def test_none(self): ref_input = {'item': None} output = python_utils.reverse_argparse(ref_input) assert output == []
def test_boolean_false(self): ref_input = {'debug': False} output = python_utils.reverse_argparse(ref_input) assert output == []
def test_boolean(self): ref_input = {'debug': True} output = python_utils.reverse_argparse(ref_input) assert output == ['--debug']