コード例 #1
0
def test_ApiSync_start_not_called_when_already_started(mocker, session_maker, homedir):
    """
    Ensure sync thread does not start when start is called if already running.
    """
    api_sync = ApiSync(mocker.MagicMock(), session_maker, mocker.MagicMock(), homedir)
    api_sync.sync_thread = mocker.MagicMock()
    api_sync.sync_thread.isRunning = mocker.MagicMock(return_value=True)

    api_sync.start(mocker.MagicMock())

    api_sync.sync_thread.start.assert_not_called()
コード例 #2
0
def test_ApiSync_start(mocker, session_maker, homedir):
    """
    Ensure sync thread starts when start is called and not already running.
    """
    api_sync = ApiSync(mocker.MagicMock(), session_maker, mocker.MagicMock(), homedir)
    api_sync.sync_thread = mocker.MagicMock()
    api_sync.sync_thread.isRunning = mocker.MagicMock(return_value=False)

    api_sync.start(mocker.MagicMock())

    api_sync.sync_thread.start.assert_called_once_with()
コード例 #3
0
def test_ApiSync_stop_calls_quit(mocker, session_maker, homedir):
    """
    Ensure stop calls QThread's quit method and api_client is None.
    """
    api_sync = ApiSync(mocker.MagicMock(), session_maker, mocker.MagicMock(), homedir)
    api_sync.sync_thread = mocker.MagicMock()
    api_sync.sync_thread.isRunning = mocker.MagicMock(return_value=True)

    api_sync.stop()

    assert api_sync.api_client is None
    api_sync.sync_thread.quit.assert_called_once_with()