예제 #1
0
def test_ApiSync_on_sync_failure_because_of_timeout(mocker, session_maker, homedir, exception):
    """
    Ensure failure handler emits failure signal that the Controller links to and sets up timer to
    fire another sync after 15 seconds if the failure reason is a RequestTimeoutError or
    ServerConnectionError.
    """
    api_sync = ApiSync(mocker.MagicMock(), session_maker, mocker.MagicMock(), homedir)
    sync_failure = mocker.patch.object(api_sync, "sync_failure")
    singleShot_fn = mocker.patch("securedrop_client.sync.QTimer.singleShot")
    error = exception()

    api_sync.on_sync_failure(error)

    sync_failure.emit.assert_called_once_with(error)
    singleShot_fn.assert_called_once_with(15000, api_sync.api_sync_bg_task.sync)
예제 #2
0
def test_ApiSync_on_sync_failure(mocker, session_maker, homedir):
    """
    Ensure failure handler emits failure signal that the Controller links to and does not fire
    another sync for errors other than RequestTimeoutError or ServerConnectionError
    """
    api_sync = ApiSync(mocker.MagicMock(), session_maker, mocker.MagicMock(), homedir)
    sync_failure = mocker.patch.object(api_sync, "sync_failure")
    singleShot_fn = mocker.patch("securedrop_client.sync.QTimer.singleShot")

    error = Exception()

    api_sync.on_sync_failure(error)

    sync_failure.emit.assert_called_once_with(error)
    singleShot_fn.assert_called_once_with(15000, api_sync.api_sync_bg_task.sync)