Skip to content

Commit

Permalink
ensure conversation is removed on source deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
heartsucker committed Jan 10, 2019
1 parent c11e751 commit a1ad28b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,31 @@ def test_Client_sync_api(homedir, config, mocker):
cl.on_sync_timeout, cl.api)


def test_Client_on_synced_remove_stale_sources(homedir, config, mocker):
"""
On an API sync, if a source no longer exists, remove it from the GUI.
Using the `config` fixture to ensure the config is written to disk.
"""
mock_source_id = 'abc123'
mock_conv_wrapper = 'mock'

gui = mocker.Mock()
gui.conversations = {mock_source_id: mock_conv_wrapper}

mock_session = mocker.MagicMock()
cl = Client('http://localhost', gui, mock_session, homedir)

mock_source = mocker.Mock()
mock_source.uuid = mock_source_id

# not that the first item does *not* have the mock_source
api_res = ([], mocker.MagicMock(), mocker.MagicMock())
cl.on_synced(api_res)

# check that the uuid is not longer in the dict
assert mock_source_id not in gui.conversations


def test_Client_last_sync_with_file(homedir, config, mocker):
"""
The flag indicating the time of the last sync with the API is stored in a
Expand Down

0 comments on commit a1ad28b

Please sign in to comment.