Skip to content

Commit

Permalink
Fix existing tests, add new unit tests to test local delete.
Browse files Browse the repository at this point in the history
  • Loading branch information
rocodes committed Mar 7, 2022
1 parent f32e2d3 commit e1b3525
Show file tree
Hide file tree
Showing 4 changed files with 471 additions and 42 deletions.
4 changes: 3 additions & 1 deletion tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5070,7 +5070,9 @@ def test_ReplyBoxWidget_enable_after_source_gets_key(mocker, session, session_ma

# now simulate a sync...
source_with_key = factory.RemoteSource(uuid=source.uuid)
storage.update_sources([source_with_key], [source], session, homedir)

# passing 'None' for skip_uuid, test that separately
storage.update_sources([source_with_key], [source], None, session, homedir)

# ... simulate the ReplyBoxWidget receiving the sync success signal
rbw._on_sync_succeeded()
Expand Down
9 changes: 8 additions & 1 deletion tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1874,9 +1874,16 @@ def test_Controller_on_delete_conversation_success(mocker, homedir):
info_logger = mocker.patch("securedrop_client.logic.logger.info")

co = Controller("http://localhost", mocker.MagicMock(), mocker.MagicMock(), homedir)
mock_storage = mocker.MagicMock()
mocker.patch("securedrop_client.logic.storage", mock_storage)

co.on_delete_conversation_success("uuid-blah")

info_logger.assert_called_once_with(
"Conversation %s successfully deleted at server", "uuid-blah"
"Conversation %s successfully scheduled for deletion at server", "uuid-blah"
)
mock_storage.delete_local_conversation_by_source_uuid.assert_called_once_with(
co.session, "uuid-blah", co.data_dir
)


Expand Down
9 changes: 9 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from securedrop_client.db import (
DeletedConversation,
DownloadError,
DownloadErrorCodes,
DraftReply,
Expand Down Expand Up @@ -349,3 +350,11 @@ def test_reply_with_download_error(session, download_error_codes):

classname = r.__class__.__name__.lower()
assert str(r) == f"cannot decrypt {classname}"


def test_deletedconversation_creation(session):
with pytest.raises(TypeError):
DeletedConversation() # must initialize with a UUID

dc = DeletedConversation(uuid="test-uuid")
assert str(dc) == "DeletedConversation (source {})".format(dc.uuid)
Loading

0 comments on commit e1b3525

Please sign in to comment.