mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
test main
This commit is contained in:
parent
59b961cb19
commit
0a4d5ceac2
@ -271,9 +271,7 @@ def search_mirrors(printer, pages, category, sort, action, search):
|
||||
return [], None
|
||||
|
||||
|
||||
def main():
|
||||
args = combine_configs(load_config(), parse_args(sys.argv[1:]))
|
||||
|
||||
def pirate_main(args):
|
||||
printer = Printer(args.color)
|
||||
|
||||
# check it transmission is running
|
||||
@ -392,5 +390,10 @@ def main():
|
||||
subprocess.call(args.transmission_command + ['-l'])
|
||||
|
||||
|
||||
def main():
|
||||
args = combine_configs(load_config(), parse_args(sys.argv[1:]))
|
||||
pirate_main(args)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import socket
|
||||
import unittest
|
||||
import subprocess
|
||||
from unittest import mock
|
||||
from unittest.mock import patch, call, MagicMock
|
||||
|
||||
@ -22,6 +23,21 @@ class TestPirate(unittest.TestCase):
|
||||
for test in tests:
|
||||
self.assertEqual(pirate.pirate.parse_cmd(*test[0]), test[1])
|
||||
|
||||
def test_main(self):
|
||||
with patch('subprocess.call') as mock_call:
|
||||
result = {
|
||||
'magnet': 'dn=derp',
|
||||
'seeds': '1',
|
||||
'leechers': '1',
|
||||
'size': ('1', 'mb'),
|
||||
'uploaded': '1',
|
||||
}
|
||||
with patch('pirate.torrent.remote', return_value=[result]) as mock_remote:
|
||||
config = pirate.pirate.parse_config_file('')
|
||||
args = pirate.pirate.combine_configs(config, pirate.pirate.parse_args(['-0', 'term', '-C', 'blah %s']))
|
||||
pirate.pirate.pirate_main(args)
|
||||
mock_call.assert_called_once_with(['blah', 'dn=derp'])
|
||||
|
||||
def test_parse_torrent_command(self):
|
||||
tests = [
|
||||
[['h'], ('h', [])],
|
||||
|
Loading…
Reference in New Issue
Block a user