From 9dd251975d2fbf339021976cf9f202c8a545c13c Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 22 Nov 2021 10:48:45 +0100 Subject: [PATCH] Test for result of callback with a callable In this case the callback should get called immediately (no wait) so it is safe to test for this callback, albeit slightly implementation-defined. Contributes to issue CURA-8539. --- tests/TestOAuth2.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/TestOAuth2.py b/tests/TestOAuth2.py index 2c039b296a..24cfe50921 100644 --- a/tests/TestOAuth2.py +++ b/tests/TestOAuth2.py @@ -1,5 +1,5 @@ from datetime import datetime -from unittest.mock import MagicMock, patch +from unittest.mock import MagicMock, Mock, patch import requests @@ -53,7 +53,11 @@ def test_cleanAuthService() -> None: # Ensure that when setting up an AuthorizationService, no data is set. authorization_service = AuthorizationService(OAUTH_SETTINGS, Preferences()) authorization_service.initialize() - assert authorization_service.getUserProfile() is None + + mock_callback = Mock() + authorization_service.getUserProfile(mock_callback) + mock_callback.assert_called_once_with(None) + assert authorization_service.getAccessToken() is None