Exemplo n.º 1
0
def test_conversation_pending_message():
    """
    Test that a conversation with a message that's not yet downloaded
    shows the right placeholder text
    """
    w = Window()
    w.controller = mock.MagicMock()
    w.main_view = mock.MagicMock()
    w._add_item_content_or = mock.MagicMock()
    mock_conview = mock.MagicMock()
    mock_source = mock.MagicMock()
    mock_source.journalistic_designation = 'Testy McTestface'

    submission = Submission(source=mock_source,
                            uuid="test",
                            size=123,
                            filename="test.msg.gpg",
                            download_url='http://test/test')

    submission.is_downloaded = False

    mock_source.collection = [submission]

    with mock.patch('securedrop_client.gui.main.ConversationView',
                    mock_conview):
        w.show_conversation_for(mock_source)
        conv = mock_conview()

        # once for source name, once for message
        assert conv.add_message.call_count == 2
        assert conv.add_message.call_args == \
            mock.call("<Message not yet downloaded>")
Exemplo n.º 2
0
def test_conversation_pending_message(mocker):
    """
    Test that a conversation with a message that's not yet downloaded
    shows the right placeholder text
    """
    w = Window('mock')
    w.controller = mocker.MagicMock()
    w.main_view = mocker.MagicMock()
    w._add_item_content_or = mocker.MagicMock()
    mock_source = mocker.MagicMock()
    mock_source.journalistic_designation = 'Testy McTestface'

    msg_uuid = str(uuid4())
    submission = Submission(source=mock_source,
                            uuid=msg_uuid,
                            size=123,
                            filename="test.msg.gpg",
                            download_url='http://test/test')

    submission.is_downloaded = False

    mock_source.collection = [submission]

    mocked_add_message = mocker.patch(
        'securedrop_client.gui.widgets.ConversationView.add_message')
    mocker.patch('securedrop_client.gui.main.QVBoxLayout')
    mocker.patch('securedrop_client.gui.main.QWidget')

    w.show_conversation_for(mock_source)

    assert mocked_add_message.call_count == 1
    assert mocked_add_message.call_args == mocker.call(
        msg_uuid, "<Message not yet downloaded>")