mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
test basic choice of torrent
This commit is contained in:
parent
83a1a0add2
commit
a9fdd5ec84
@ -7,6 +7,7 @@ import socket
|
|||||||
import urllib.request as request
|
import urllib.request as request
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import sys
|
import sys
|
||||||
|
import builtins
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
import webbrowser
|
import webbrowser
|
||||||
@ -325,7 +326,7 @@ def pirate_main(args):
|
|||||||
printer.print("\nSelect links (Type 'h' for more options"
|
printer.print("\nSelect links (Type 'h' for more options"
|
||||||
", 'q' to quit)", end='\b', color='alt')
|
", 'q' to quit)", end='\b', color='alt')
|
||||||
try:
|
try:
|
||||||
l = input(': ')
|
l = builtins.input(': ')
|
||||||
except (KeyboardInterrupt, EOFError):
|
except (KeyboardInterrupt, EOFError):
|
||||||
printer.print('\nCancelled.')
|
printer.print('\nCancelled.')
|
||||||
return
|
return
|
||||||
|
@ -23,20 +23,36 @@ 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):
|
@patch('subprocess.call')
|
||||||
with patch('subprocess.call') as mock_call:
|
def test_main(self, mock_call):
|
||||||
result = {
|
result = {
|
||||||
'magnet': 'dn=derp',
|
'magnet': 'dn=derp',
|
||||||
'seeds': '1',
|
'seeds': '1',
|
||||||
'leechers': '1',
|
'leechers': '1',
|
||||||
'size': ('1', 'mb'),
|
'size': ('1', 'mb'),
|
||||||
'uploaded': '1',
|
'uploaded': '1',
|
||||||
}
|
}
|
||||||
with patch('pirate.torrent.remote', return_value=[result]) as mock_remote:
|
with patch('pirate.torrent.remote', return_value=[result]) as mock_remote:
|
||||||
config = pirate.pirate.parse_config_file('')
|
config = pirate.pirate.parse_config_file('')
|
||||||
args = pirate.pirate.combine_configs(config, pirate.pirate.parse_args(['-0', 'term', '-C', 'blah %s']))
|
args = pirate.pirate.combine_configs(config, pirate.pirate.parse_args(['-0', 'term', '-C', 'blah %s']))
|
||||||
pirate.pirate.pirate_main(args)
|
pirate.pirate.pirate_main(args)
|
||||||
mock_call.assert_called_once_with(['blah', 'dn=derp'])
|
mock_call.assert_called_once_with(['blah', 'dn=derp'])
|
||||||
|
|
||||||
|
@patch('pirate.pirate.builtins.input', return_value='0')
|
||||||
|
@patch('subprocess.call')
|
||||||
|
def test_main_choice(self, mock_call, mock_input):
|
||||||
|
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(['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 = [
|
||||||
|
Loading…
Reference in New Issue
Block a user