Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
timruffles committed Nov 11, 2018
1 parent db266ca commit 3b40ed7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ def test_ToolBar_setup():
assert tb.controller == mock_controller


def test_ToolBar_set_logged_in_as():
"""Given a username, the user_state is updated and login/logout
buttons, and refresh buttons, are in the correct state.
"""
tb = ToolBar(None)
tb.user_state = mock.MagicMock()
tb.login = mock.MagicMock()
tb.logout = mock.MagicMock()
tb.refresh = mock.MagicMock()
tb.set_logged_in_as('test')
tb.user_state.setText.assert_called_once_with('Signed in as: test')
tb.login.setVisible.assert_called_once_with(False)
tb.logout.setVisible.assert_called_once_with(True)
tb.refresh.setVisible.assert_called_once_with(True)

def test_ToolBar_set_logged_in_as():
"""Given a username, the user_state is updated and login/logout
buttons, and refresh buttons, are in the correct state.
Expand Down Expand Up @@ -95,6 +110,16 @@ def test_ToolBar_on_refresh_clicked():
tb.on_refresh_clicked()
tb.controller.sync_api.assert_called_once_with()

def test_ToolBar_sync_event():
"""Toggles refresh button when syncing
"""
tb = ToolBar(None)
tb._on_sync_event('syncing')
assert tb.refresh.isEnabled() == False

tb._on_sync_event('synced')
assert tb.refresh.isEnabled() == True


def test_MainView_init():
"""
Expand Down

0 comments on commit 3b40ed7

Please sign in to comment.