mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-09 14:55:03 -06:00
Add tests for loginWithForcedLogout() in account
CURA-7427
This commit is contained in:
parent
e3e767f4b9
commit
96387ef2aa
2 changed files with 22 additions and 2 deletions
|
@ -23,7 +23,7 @@ def test_login():
|
|||
account.login()
|
||||
mocked_auth_service.startAuthorizationFlow.assert_called_once_with()
|
||||
|
||||
# Fake a sucesfull login
|
||||
# Fake a successful login
|
||||
account._onLoginStateChanged(True)
|
||||
|
||||
# Attempting to log in again shouldn't change anything.
|
||||
|
@ -31,6 +31,26 @@ def test_login():
|
|||
mocked_auth_service.startAuthorizationFlow.assert_called_once_with()
|
||||
|
||||
|
||||
def test_loginWithForcedLogout():
|
||||
account = Account(MagicMock())
|
||||
mocked_auth_service = MagicMock()
|
||||
account._authorization_service = mocked_auth_service
|
||||
account.logout = MagicMock()
|
||||
|
||||
# Fake a successful login
|
||||
account._onLoginStateChanged(True)
|
||||
account.loginWithForcedLogout()
|
||||
# Make sure logout is called once
|
||||
account.logout.assert_called_once_with()
|
||||
mocked_auth_service.startAuthorizationFlow.assert_called_once_with(True)
|
||||
|
||||
account._onLoginStateChanged(False)
|
||||
account.loginWithForcedLogout()
|
||||
# If we are not logged in previously, logout shouldn't be called again
|
||||
account.logout.assert_called_once_with()
|
||||
assert mocked_auth_service.startAuthorizationFlow.call_count == 2
|
||||
|
||||
|
||||
def test_initialize():
|
||||
account = Account(MagicMock())
|
||||
mocked_auth_service = MagicMock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue