def test_ConversationView_add_reply(): """ Adding a reply results in a new ReplyWidget added to the layout. """ cv = ConversationView(None) cv.controller = mock.MagicMock() cv.conversation_layout = mock.MagicMock() cv.add_reply('hello') assert cv.conversation_layout.addWidget.call_count == 1 cal = cv.conversation_layout.addWidget.call_args_list assert isinstance(cal[0][0][0], ReplyWidget)
def test_ConversationView_add_downloaded_file(): """ Adding a file results in a new FileWidget added to the layout with the proper QLabel. """ cv = ConversationView(None) cv.controller = mock.MagicMock() cv.conversation_layout = mock.MagicMock() mock_source = mock.MagicMock() mock_file = mock.MagicMock() mock_file.is_downloaded = True with mock.patch('securedrop_client.gui.widgets.QLabel') as mock_label, \ mock.patch('securedrop_client.gui.widgets.QHBoxLayout.addWidget'),\ mock.patch('securedrop_client.gui.widgets.FileWidget.setLayout'): cv.add_file(mock_source, mock_file) mock_label.assert_called_with("Open") assert cv.conversation_layout.addWidget.call_count == 1 cal = cv.conversation_layout.addWidget.call_args_list assert isinstance(cal[0][0][0], FileWidget)