Add tests for loginWithForcedLogout() in account

CURA-7427
This commit is contained in:
Kostas Karmas 2020-05-12 13:06:47 +02:00
parent e3e767f4b9
commit 96387ef2aa
2 changed files with 22 additions and 2 deletions

View file

@ -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()