Skip to content

Commit

Permalink
Update StarToggleButton tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmol committed Mar 13, 2020
1 parent 3bc0639 commit 51bfcbc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,10 +1112,13 @@ def test_StarToggleButton_on_authentication_changed_while_authenticated_and_not_
should result in the button being unchecked.
"""
source = mocker.MagicMock()
source.is_starred = False
stb = StarToggleButton(source=source)
stb.setChecked(False)
stb.on_toggle = mocker.MagicMock()
assert stb.isChecked() is False

stb.on_authentication_changed(authenticated=True)
assert stb.isChecked() is False

stb.toggle()

Expand Down Expand Up @@ -1150,7 +1153,6 @@ def test_StarToggleButton_on_toggle(mocker):
stb.on_toggle()

stb.controller.update_star.assert_called_once_with(source, stb.on_update)
assert stb.isCheckable() is True


def test_StarToggleButton_on_toggle_offline(mocker):
Expand All @@ -1162,9 +1164,7 @@ def test_StarToggleButton_on_toggle_offline(mocker):
stb.controller = mocker.MagicMock()

stb.on_toggle_offline()

stb.controller.on_action_requiring_login.assert_called_once_with()
assert stb.isCheckable() is False


def test_StarToggleButton_on_toggle_offline_when_checked(mocker):
Expand All @@ -1176,12 +1176,15 @@ def test_StarToggleButton_on_toggle_offline_when_checked(mocker):
stb = StarToggleButton(source)
stb.controller = mocker.MagicMock()
set_icon_fn = mocker.patch('securedrop_client.gui.SvgToggleButton.set_icon')
stb.on_toggle_offline()

stb.controller.on_action_requiring_login.assert_called_once_with()
# go offline
stb.on_authentication_changed(False)
assert stb.isCheckable() is False
set_icon_fn.assert_called_with(on='star_on.svg', off='star_on.svg')

stb.on_toggle_offline()
stb.controller.on_action_requiring_login.assert_called_once_with()


def test_StarToggleButton_on_update(mocker):
"""
Expand Down

0 comments on commit 51bfcbc

Please sign in to comment.