Skip to content

Commit

Permalink
Test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrose committed Oct 26, 2018
1 parent 07a9cec commit dd6efed
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def setup_class(cls):
@staticmethod
def socket_mock_generator(already_bound_errno=98):
namespace = set()

def kernel_bind(addr):
if addr in namespace:
error = OSError()
Expand Down Expand Up @@ -89,12 +88,9 @@ def test_same_name(self, mock_msgbox, mock_exit):
def test_unknown_kernel_error(self, mock_msgbox, mock_exit):
mock_socket = self.socket_mock_generator(131) # crazy unexpected error
with mock.patch('securedrop_client.app.socket', new=mock_socket):
try:
with pytest.raises(OSError):
prevent_second_instance(self.mock_app, 'name1')
prevent_second_instance(self.mock_app, 'name1')
assert False # an unhandled exception should have occurred
except OSError:
assert True


def test_start_app(safe_tmpdir):
Expand All @@ -111,7 +107,7 @@ def test_start_app(safe_tmpdir):
mock.patch('securedrop_client.app.QApplication') as mock_app, \
mock.patch('securedrop_client.app.Window') as mock_win, \
mock.patch('securedrop_client.app.Client') as mock_client, \
mock.patch('securedrop_client.app.socket'), \
mock.patch('securedrop_client.app.prevent_second_instance'), \
mock.patch('securedrop_client.app.sys') as mock_sys, \
mock.patch('securedrop_client.app.sessionmaker',
return_value=mock_session_class):
Expand Down Expand Up @@ -180,7 +176,7 @@ def test_create_app_dir_permissions(tmpdir):
mock.patch('securedrop_client.app.Window') as mock_win, \
mock.patch('securedrop_client.app.Client') as mock_client, \
mock.patch('securedrop_client.app.sys') as mock_sys, \
mock.patch('securedrop_client.app.socket'), \
mock.patch('securedrop_client.app.prevent_second_instance'), \
mock.patch('securedrop_client.app.sessionmaker',
return_value=mock_session_class):

Expand Down Expand Up @@ -233,7 +229,7 @@ def fake_known_args():
def test_signal_interception():
# check that initializing an app calls configure_signal_handlers
with mock.patch('securedrop_client.app.QApplication'), \
mock.patch('securedrop_client.app.socket'), \
mock.patch('securedrop_client.app.prevent_second_instance'), \
mock.patch('sys.exit'), \
mock.patch('securedrop_client.models.make_engine'), \
mock.patch('securedrop_client.app.init'), \
Expand Down

0 comments on commit dd6efed

Please sign in to comment.