mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
commit
83a1a0add2
@ -271,9 +271,7 @@ def search_mirrors(printer, pages, category, sort, action, search):
|
|||||||
return [], None
|
return [], None
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def pirate_main(args):
|
||||||
args = combine_configs(load_config(), parse_args(sys.argv[1:]))
|
|
||||||
|
|
||||||
printer = Printer(args.color)
|
printer = Printer(args.color)
|
||||||
|
|
||||||
# check it transmission is running
|
# check it transmission is running
|
||||||
@ -392,5 +390,10 @@ def main():
|
|||||||
subprocess.call(args.transmission_command + ['-l'])
|
subprocess.call(args.transmission_command + ['-l'])
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = combine_configs(load_config(), parse_args(sys.argv[1:]))
|
||||||
|
pirate_main(args)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import socket
|
import socket
|
||||||
import unittest
|
import unittest
|
||||||
|
import subprocess
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from unittest.mock import patch, call, MagicMock
|
from unittest.mock import patch, call, MagicMock
|
||||||
|
|
||||||
@ -22,6 +23,21 @@ class TestPirate(unittest.TestCase):
|
|||||||
for test in tests:
|
for test in tests:
|
||||||
self.assertEqual(pirate.pirate.parse_cmd(*test[0]), test[1])
|
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):
|
def test_parse_torrent_command(self):
|
||||||
tests = [
|
tests = [
|
||||||
[['h'], ('h', [])],
|
[['h'], ('h', [])],
|
||||||
|
Loading…
Reference in New Issue
Block a user