mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
fix bug and test combine_configs better
This commit is contained in:
parent
f43e08c18c
commit
7ee1bbbccf
@ -182,12 +182,12 @@ def combine_configs(config, args):
|
||||
args.action = 'browse'
|
||||
elif args.recent:
|
||||
args.action = 'recent'
|
||||
elif len(args.search) == 0:
|
||||
args.action = 'top'
|
||||
elif args.list_categories:
|
||||
args.action = 'list_categories'
|
||||
elif args.list_sorts:
|
||||
args.action = 'list_sorts'
|
||||
elif len(args.search) == 0:
|
||||
args.action = 'top'
|
||||
else:
|
||||
args.action = 'search'
|
||||
|
||||
|
@ -83,19 +83,30 @@ class TestPirate(unittest.TestCase):
|
||||
|
||||
def test_parse_args(self):
|
||||
tests = [
|
||||
(['-b'], {'action': 'browse'}),
|
||||
([], {'action': 'top'}),
|
||||
(['-R'], {'action': 'recent'}),
|
||||
(['internets'], {'action': 'search', 'search': ['internets']}),
|
||||
(['internets lol', 'lel'], {'action': 'search', 'search': ['internets lol', 'lel']}),
|
||||
('', ['-b'], {'action': 'browse'}),
|
||||
('', [], {'action': 'top'}),
|
||||
('', ['-R'], {'action': 'recent'}),
|
||||
('', ['-l'], {'action': 'list_categories'}),
|
||||
('', ['--list_sorts'], {'action': 'list_sorts'}),
|
||||
('', ['term'], {'action': 'search', 'source': 'tpb'}),
|
||||
('', ['-L', 'filename', 'term'], {'action': 'search', 'source': 'local_tpb', 'database': 'filename'}),
|
||||
('', ['term', '-S', 'dir'], {'action': 'search', 'save_directory': 'dir'}),
|
||||
('', ['-P', '1337'], {'transmission_command': ['transmission-remote', '1337']}),
|
||||
('', ['term'], {'output': 'browser_open'}),
|
||||
('', ['term', '-t'], {'output': 'transmission'}),
|
||||
('', ['term', '--save-magnets'], {'output': 'save_magnet_files'}),
|
||||
('', ['term', '--save-torrents'], {'output': 'save_torrent_files'}),
|
||||
('', ['term', '-C', 'command'], {'output': 'open_command', 'open_command': 'command'}),
|
||||
('', ['internets'], {'action': 'search', 'search': ['internets']}),
|
||||
('', ['internets lol', 'lel'], {'action': 'search', 'search': ['internets lol', 'lel']}),
|
||||
]
|
||||
for test in tests:
|
||||
args = pirate.pirate.parse_args(test[0])
|
||||
config = pirate.pirate.parse_config_file('')
|
||||
args = pirate.pirate.parse_args(test[1])
|
||||
config = pirate.pirate.parse_config_file(test[0])
|
||||
args = pirate.pirate.combine_configs(config, args)
|
||||
for option in test[1].keys():
|
||||
for option in test[2].keys():
|
||||
value = getattr(args, option)
|
||||
self.assertEqual(test[1][option], value)
|
||||
self.assertEqual(test[2][option], value)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user