Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure UI remains responsive at all times during sync with server. #733

Merged
merged 1 commit into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion securedrop_client/api_jobs/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def call_api(self, api_client: API, session: Session) -> Any:
# TODO: Once https://github.com/freedomofpress/securedrop-client/issues/648, we will want to
# pass the default request timeout to api calls instead of setting it on the api object
# directly.
api_client.default_request_timeout = 20
api_client.default_request_timeout = 40
remote_sources, remote_submissions, remote_replies = \
get_remote_data(api_client)

Expand Down
3 changes: 0 additions & 3 deletions securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ def on_authenticate_success(self, result):
self.api.journalist_last_name,
self.session)
self.gui.show_main_window(user)
self.update_sources()
self.api_job_queue.login(self.api)
self.sync_api()
self.is_authenticated = True
Expand Down Expand Up @@ -533,7 +532,6 @@ def on_message_download_success(self, uuid: str) -> None:
self.gui.clear_error_status() # remove any permanent error status message
message = storage.get_message(self.session, uuid)
self.message_ready.emit(message.uuid, message.content)
self.update_sources()

def on_message_download_failure(self, exception: Exception) -> None:
"""
Expand Down Expand Up @@ -711,7 +709,6 @@ def on_file_download_success(self, result: Any) -> None:
"""
self.gui.clear_error_status() # remove any permanent error status message
self.file_ready.emit(result)
self.update_sources()

def on_file_download_failure(self, exception: Exception) -> None:
"""
Expand Down
6 changes: 0 additions & 6 deletions tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def test_Controller_on_authenticate_success(homedir, config, mocker, session_mak
mock_api_job_queue = mocker.patch("securedrop_client.logic.ApiJobQueue")
co = Controller('http://localhost', mock_gui, session_maker, homedir)
co.sync_api = mocker.MagicMock()
co.update_sources = mocker.MagicMock()
co.session.add(user)
co.session.commit()
co.api = mocker.MagicMock()
Expand All @@ -211,7 +210,6 @@ def test_Controller_on_authenticate_success(homedir, config, mocker, session_mak
co.sync_api.assert_called_once_with()
assert co.is_authenticated
assert mock_api_job_queue.called
co.update_sources.assert_called_once_with()
login.assert_called_with(co.api)
co.resume_queues.assert_called_once_with()

Expand Down Expand Up @@ -736,7 +734,6 @@ def test_Controller_on_file_downloaded_success(homedir, config, mocker, session_
mock_gui = mocker.MagicMock()

co = Controller('http://localhost', mock_gui, session_maker, homedir)
co.update_sources = mocker.MagicMock()

# signal when file is downloaded
mock_file_ready = mocker.patch.object(co, 'file_ready')
Expand All @@ -745,7 +742,6 @@ def test_Controller_on_file_downloaded_success(homedir, config, mocker, session_
co.on_file_download_success(mock_uuid)

mock_file_ready.emit.assert_called_once_with(mock_uuid)
co.update_sources.assert_called_once_with()


def test_Controller_on_file_downloaded_api_failure(homedir, config, mocker, session_maker):
Expand Down Expand Up @@ -1178,15 +1174,13 @@ def test_Controller_on_message_downloaded_success(mocker, homedir, session_maker
Check that a successful download emits proper signal.
"""
co = Controller('http://localhost', mocker.MagicMock(), session_maker, homedir)
co.update_sources = mocker.MagicMock()
message_ready = mocker.patch.object(co, 'message_ready')
message = factory.Message(source=factory.Source())
mocker.patch('securedrop_client.storage.get_message', return_value=message)

co.on_message_download_success(message.uuid)

message_ready.emit.assert_called_once_with(message.uuid, message.content)
co.update_sources.assert_called_once_with()


def test_Controller_on_message_downloaded_failure(mocker, homedir, session_maker):
Expand Down