Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests/API
diff options
context:
space:
mode:
authorKostas Karmas <konskarm@gmail.com>2020-05-12 17:54:41 +0300
committerKostas Karmas <konskarm@gmail.com>2020-05-12 17:54:41 +0300
commiteac4d3e463c659f9f18ca3a3d7aff603f2561933 (patch)
tree87e39a750592de8f9ef66ea2318079e78ff0aea5 /tests/API
parent898ca852f0e4c2a65822e3591ea823342ed1a741 (diff)
Make login parametrized with a force_logout boolean
Instead of using a separate function to force logging out before login, login now has a boolean parameter that instructs it to logout before loging in again, if the user is alread logged in. It then starts the authorization with a force browser logout first. CURA-7427
Diffstat (limited to 'tests/API')
-rw-r--r--tests/API/TestAccount.py26
1 files changed, 7 insertions, 19 deletions
diff --git a/tests/API/TestAccount.py b/tests/API/TestAccount.py
index 1b23947cc0..09091ba7e0 100644
--- a/tests/API/TestAccount.py
+++ b/tests/API/TestAccount.py
@@ -19,35 +19,23 @@ def test_login():
account = Account(MagicMock())
mocked_auth_service = MagicMock()
account._authorization_service = mocked_auth_service
+ account.logout = MagicMock()
account.login()
- mocked_auth_service.startAuthorizationFlow.assert_called_once_with()
+ mocked_auth_service.startAuthorizationFlow.assert_called_once_with(False)
# Fake a successful login
account._onLoginStateChanged(True)
# Attempting to log in again shouldn't change anything.
account.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)
+ mocked_auth_service.startAuthorizationFlow.assert_called_once_with(False)
- account._onLoginStateChanged(False)
- account.loginWithForcedLogout()
- # If we are not logged in previously, logout shouldn't be called again
+ # Attempting to log in with force_logout_before_login as True should call the logout before calling the
+ # startAuthorizationFlow(True).
+ account.login(force_logout_before_login=True)
account.logout.assert_called_once_with()
+ mocked_auth_service.startAuthorizationFlow.assert_called_with(True)
assert mocked_auth_service.startAuthorizationFlow.call_count == 2