mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-20 17:19:09 +08:00
Add tests for loginWithForcedLogout() in account
CURA-7427
This commit is contained in:
parent
e3e767f4b9
commit
96387ef2aa
@ -99,7 +99,7 @@ class Account(QObject):
|
|||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def loginWithForcedLogout(self) -> None:
|
def loginWithForcedLogout(self) -> None:
|
||||||
"""
|
"""
|
||||||
Forces a logout from Cura and then initiates the authorization flow with the force_logout_from_mycloud variable
|
Forces a logout from Cura and then initiates the authorization flow with the force_browser_logout variable
|
||||||
as true, to sync the accounts in Cura and in the browser.
|
as true, to sync the accounts in Cura and in the browser.
|
||||||
|
|
||||||
:return: None
|
:return: None
|
||||||
|
@ -23,7 +23,7 @@ def test_login():
|
|||||||
account.login()
|
account.login()
|
||||||
mocked_auth_service.startAuthorizationFlow.assert_called_once_with()
|
mocked_auth_service.startAuthorizationFlow.assert_called_once_with()
|
||||||
|
|
||||||
# Fake a sucesfull login
|
# Fake a successful login
|
||||||
account._onLoginStateChanged(True)
|
account._onLoginStateChanged(True)
|
||||||
|
|
||||||
# Attempting to log in again shouldn't change anything.
|
# Attempting to log in again shouldn't change anything.
|
||||||
@ -31,6 +31,26 @@ def test_login():
|
|||||||
mocked_auth_service.startAuthorizationFlow.assert_called_once_with()
|
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():
|
def test_initialize():
|
||||||
account = Account(MagicMock())
|
account = Account(MagicMock())
|
||||||
mocked_auth_service = MagicMock()
|
mocked_auth_service = MagicMock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user