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
diff options
context:
space:
mode:
authorJaime van Kessel <nallath@gmail.com>2018-09-26 18:23:36 +0300
committerJaime van Kessel <nallath@gmail.com>2018-09-26 18:23:36 +0300
commitd5dbf91a4f90892aa81871386589f2d3f35008d4 (patch)
tree7791f6495f90c8bb75b25c478f89564d861fc9f6 /tests/TestOAuth2.py
parent16ff1c371236d8dc01daee4694858b51ee5250e7 (diff)
Switch unit test to use decoratior instead of with waterfall
CURA-5744
Diffstat (limited to 'tests/TestOAuth2.py')
-rw-r--r--tests/TestOAuth2.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/TestOAuth2.py b/tests/TestOAuth2.py
index 7deb712aea..312d71fd5f 100644
--- a/tests/TestOAuth2.py
+++ b/tests/TestOAuth2.py
@@ -55,22 +55,22 @@ def test_failedLogin() -> None:
assert authorization_service.getAccessToken() is None
-def test_localAuthServer() -> None:
+@patch.object(LocalAuthorizationServer, "stop")
+@patch.object(LocalAuthorizationServer, "start")
+@patch.object(webbrowser, "open_new")
+def test_localAuthServer(webbrowser_open, start_auth_server, stop_auth_server) -> None:
preferences = Preferences()
authorization_service = AuthorizationService(preferences, OAUTH_SETTINGS)
- with patch.object(webbrowser, "open_new") as webrowser_open:
- with patch.object(LocalAuthorizationServer, "start") as start_auth_server:
- with patch.object(LocalAuthorizationServer, "stop") as stop_auth_server:
- authorization_service.startAuthorizationFlow()
- assert webrowser_open.call_count == 1
-
- # Ensure that the Authorization service tried to start the server.
- assert start_auth_server.call_count == 1
- assert stop_auth_server.call_count == 0
- authorization_service._onAuthStateChanged(FAILED_AUTH_RESPONSE)
-
- # Ensure that it stopped the server.
- assert stop_auth_server.call_count == 1
+ authorization_service.startAuthorizationFlow()
+ assert webbrowser_open.call_count == 1
+
+ # Ensure that the Authorization service tried to start the server.
+ assert start_auth_server.call_count == 1
+ assert stop_auth_server.call_count == 0
+ authorization_service._onAuthStateChanged(FAILED_AUTH_RESPONSE)
+
+ # Ensure that it stopped the server.
+ assert stop_auth_server.call_count == 1
def test_loginAndLogout() -> None: