1
0
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:
Viktor Stanchev 2015-09-20 17:22:31 -07:00
parent 83a1a0add2
commit a9fdd5ec84
2 changed files with 32 additions and 15 deletions

View File

@ -7,6 +7,7 @@ import socket
import urllib.request as request
import urllib.error
import sys
import builtins
from collections import OrderedDict
import webbrowser
@ -325,7 +326,7 @@ def pirate_main(args):
printer.print("\nSelect links (Type 'h' for more options"
", 'q' to quit)", end='\b', color='alt')
try:
l = input(': ')
l = builtins.input(': ')
except (KeyboardInterrupt, EOFError):
printer.print('\nCancelled.')
return

View File

@ -23,20 +23,36 @@ 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'])
@patch('subprocess.call')
def test_main(self, 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'])
@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):
tests = [