The code for Tails's firewall-punching was refactored without updating the tests. This updates the tests.

This commit is contained in:
Mason Donahue 2014-08-23 16:57:28 -05:00
parent 8ff6a000ad
commit 925316339c

View file

@ -21,40 +21,6 @@ class MockSubprocess():
def last_call_args(self):
return self.last_call
def test_tails_open_port():
"tails_open_port() calls iptables with ACCEPT arg"
onionshare.get_platform = lambda: 'Tails'
onionshare.strings = {'punching_a_hole': ''}
mock_subprocess = MockSubprocess()
onionshare.subprocess = mock_subprocess
onionshare.tails_open_port('port')
expected_call = [
'/sbin/iptables', '-I', 'OUTPUT',
'-o', 'lo', '-p',
'tcp', '--dport', 'port', '-j', 'ACCEPT'
]
actual_call = mock_subprocess.last_call_args()
assert actual_call == expected_call
def test_tails_close_port():
"tails_close_port() calls iptables with REJECT arg"
onionshare.get_platform = lambda: 'Tails'
onionshare.strings = {'closing_hole': ''}
mock_subprocess = MockSubprocess()
onionshare.subprocess = mock_subprocess
onionshare.tails_close_port('port')
expected_call = [
'/sbin/iptables', '-I', 'OUTPUT',
'-o', 'lo', '-p',
'tcp', '--dport', 'port', '-j', 'REJECT'
]
actual_call = mock_subprocess.last_call_args()
assert actual_call == expected_call
def test_load_strings_defaults_to_english():
"load_strings() loads English by default"
locale.getdefaultlocale = lambda: ('en_US', 'UTF-8')