Skip to content

Commit

Permalink
fix most failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deeplow committed Oct 30, 2019
1 parent a1bddcd commit 669fe05
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import html

from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QMessageBox, QMainWindow, QTextEdit
from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QMessageBox, QMainWindow
from PyQt5.QtCore import Qt, QEvent
from sqlalchemy.orm import scoped_session, sessionmaker

Expand All @@ -14,8 +14,8 @@
SpeechBubble, MessageWidget, ReplyWidget, FileWidget, ConversationView, \
DeleteSourceMessageBox, DeleteSourceAction, SourceMenu, TopPane, LeftPane, RefreshButton, \
ErrorStatusBar, ActivityStatusBar, UserProfile, UserButton, UserMenu, LoginButton, \
ReplyBoxWidget, SourceConversationWrapper, StarToggleButton, LoginOfflineLink, LoginErrorBar, \
EmptyConversationView, ExportDialog
ReplyBoxWidget, ReplyTextEdit, SourceConversationWrapper, StarToggleButton, LoginOfflineLink, \
LoginErrorBar, EmptyConversationView, ExportDialog


app = QApplication([])
Expand Down Expand Up @@ -2233,7 +2233,8 @@ def test_ReplyBoxWidget_send_reply(mocker):
on_reply_sent_fn = mocker.MagicMock()
scw.conversation_view.on_reply_sent = on_reply_sent_fn
scw.reply_box.reply_sent = mocker.MagicMock()
scw.reply_box.text_edit = QTextEdit('Alles für Alle')
scw.reply_box.text_edit = ReplyTextEdit(source, controller)
scw.reply_box.text_edit.setPlainText('Alles für Alle')

scw.reply_box.send_reply()

Expand All @@ -2249,7 +2250,7 @@ def test_ReplyBoxWidget_send_reply_does_not_send_empty_string(mocker):
source = mocker.MagicMock()
controller = mocker.MagicMock()
rb = ReplyBoxWidget(source, controller)
rb.text_edit = QTextEdit()
rb.text_edit = ReplyTextEdit(source, controller)
assert not rb.text_edit.toPlainText()

rb.send_reply()
Expand Down Expand Up @@ -2347,27 +2348,29 @@ def test_ReplyBoxWidget_enable(mocker):
source = mocker.MagicMock()
controller = mocker.MagicMock()
rb = ReplyBoxWidget(source, controller)
rb.text_edit = QTextEdit()
rb.text_edit = ReplyTextEdit(source, controller)
rb.text_edit.set_logged_in = mocker.MagicMock()
rb.send_button = mocker.MagicMock()

rb.enable()

assert rb.text_edit.isEnabled()
assert rb.text_edit.toPlainText() == ''
rb.text_edit.set_logged_in.assert_called_once_with()
rb.send_button.show.assert_called_once_with()


def test_ReplyBoxWidget_disable(mocker):
source = mocker.MagicMock()
controller = mocker.MagicMock()
rb = ReplyBoxWidget(source, controller)
rb.text_edit = QTextEdit()
rb.text_edit = ReplyTextEdit(source, controller)
rb.text_edit.set_logged_out = mocker.MagicMock()
rb.send_button = mocker.MagicMock()

rb.disable()

assert not rb.text_edit.isEnabled()
assert rb.text_edit.toPlainText() == 'You need to log in to send replies.'
assert rb.text_edit.toPlainText() == ''
rb.text_edit.set_logged_out.assert_called_once_with()
rb.send_button.hide.assert_called_once_with()


Expand Down

0 comments on commit 669fe05

Please sign in to comment.