Skip to content

Commit

Permalink
update tests for updating speech bubble text
Browse files Browse the repository at this point in the history
  • Loading branch information
Allie Crevier committed Apr 13, 2020
1 parent c1bb6f7 commit 974189d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions securedrop_client/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ class SecureQPlainTextEdit(QPlainTextEdit):
HEIGHT_BASE = 60
LINE_HEIGHT = 20

def __init__(self, text: str = ""):
def __init__(self, text: str = '') -> None:
super().__init__()
self.setReadOnly(True)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.document().setTextWidth(self.MAX_TEXT_WIDTH)
self.height = self.HEIGHT_BASE
self.setPlainText(text)

def setPlainText(self, text):
def setPlainText(self, text: str) -> None:
super().setPlainText(text)

total_line_count = 0
Expand Down
10 changes: 5 additions & 5 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ def test_SpeechBubble_init(mocker):
sb = SpeechBubble('mock id', 'hello', mock_signal, 0)
ss = sb.styleSheet()

sb.message.text() == 'hello'
sb.message.toPlainText() == 'hello'
assert mock_connect.called
assert 'background-color' in ss

Expand All @@ -2047,11 +2047,11 @@ def test_SpeechBubble_update_text(mocker):

new_msg = 'new message'
sb._update_text('mock_source_uuid', msg_id, new_msg)
assert sb.message.text() == new_msg
assert sb.message.toPlainText() == new_msg

newer_msg = 'an even newer message'
sb._update_text('mock_source_uuid', msg_id + 'xxxxx', newer_msg)
assert sb.message.text() == new_msg
assert sb.message.toPlainText() == new_msg


def test_SpeechBubble_html_init(mocker):
Expand All @@ -2062,7 +2062,7 @@ def test_SpeechBubble_html_init(mocker):
mock_signal = mocker.MagicMock()

bubble = SpeechBubble('mock id', '<b>hello</b>', mock_signal, 0)
assert bubble.message.text() == '<b>hello</b>'
assert bubble.message.toPlainText() == '<b>hello</b>'


def test_SpeechBubble_with_apostrophe_in_text(mocker):
Expand All @@ -2071,7 +2071,7 @@ def test_SpeechBubble_with_apostrophe_in_text(mocker):

message = "I'm sure, you are reading my message."
bubble = SpeechBubble('mock id', message, mock_signal, 0)
assert bubble.message.text() == message
assert bubble.message.toPlainText() == message


def test_MessageWidget_init(mocker):
Expand Down

0 comments on commit 974189d

Please sign in to comment.