diff options
author | Jaime van Kessel <nallath@gmail.com> | 2018-09-27 14:07:37 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2018-09-27 14:07:37 +0300 |
commit | 47c5dbaf840cf2f4eca3575b46ea200d3229689e (patch) | |
tree | 167d026fe33b1a2063b9b8fca7ff4dfdacc01816 /tests/TestOAuth2.py | |
parent | 202cf698c3061f1dee712b69a18ee8ae256f8310 (diff) |
Add extra unit test that tests the storing and loading of data to the preferences
Diffstat (limited to 'tests/TestOAuth2.py')
-rw-r--r-- | tests/TestOAuth2.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/TestOAuth2.py b/tests/TestOAuth2.py index 22bf0656ef..78585804f5 100644 --- a/tests/TestOAuth2.py +++ b/tests/TestOAuth2.py @@ -55,6 +55,23 @@ def test_failedLogin() -> None: assert authorization_service.getAccessToken() is None +@patch.object(AuthorizationService, "getUserProfile", return_value=UserProfile()) +def test_storeAuthData(get_user_profile) -> None: + preferences = Preferences() + authorization_service = AuthorizationService(preferences, OAUTH_SETTINGS) + + # Write stuff to the preferences. + authorization_service._storeAuthData(SUCCESFULL_AUTH_RESPONSE) + preference_value = preferences.getValue(OAUTH_SETTINGS.AUTH_DATA_PREFERENCE_KEY) + # Check that something was actually put in the preferences + assert preference_value is not None and preference_value != {} + + # Create a second auth service, so we can load the data. + second_auth_service = AuthorizationService(preferences, OAUTH_SETTINGS) + second_auth_service.loadAuthDataFromPreferences() + assert second_auth_service.getAccessToken() == SUCCESFULL_AUTH_RESPONSE.access_token + + @patch.object(LocalAuthorizationServer, "stop") @patch.object(LocalAuthorizationServer, "start") @patch.object(webbrowser, "open_new") |