refactor authtypes

This commit is contained in:
sigma67 2023-12-31 11:18:39 +01:00
commit c848e50b3b
No known key found for this signature in database
GPG key ID: 1C314227DF0103D0
5 changed files with 50 additions and 36 deletions

View file

@ -8,6 +8,7 @@ from unittest import mock
from requests import Response
from ytmusicapi.auth.types import AuthType
from ytmusicapi.setup import main, setup # noqa: E402
from ytmusicapi.ytmusic import YTMusic, OAuthCredentials # noqa: E402
from ytmusicapi.constants import OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET
@ -82,7 +83,7 @@ class TestYTMusic(unittest.TestCase):
# OAUTH
###############
# 000 so test is run first and fresh token is available to others
def test_000_oauth_tokens(self):
def test_oauth_tokens(self):
# ensure instance initialized token
self.assertIsNotNone(self.yt_oauth._token)
@ -115,14 +116,14 @@ class TestYTMusic(unittest.TestCase):
# ensure token is updating local file
self.assertNotEqual(first_json, second_json)
def test_alt_oauth(self):
def test_oauth_custom_client(self):
# ensure client works/ignores alt if browser credentials passed as auth
self.assertFalse(self.yt_alt_oauth.is_alt_oauth)
self.assertNotEqual(self.yt_alt_oauth.auth_type, AuthType.OAUTH_CUSTOM_CLIENT)
with open(oauth_filepath, 'r') as f:
token_dict = json.load(f)
# oauth token dict entry and alt
self.yt_alt_oauth = YTMusic(token_dict, oauth_credentials=alt_oauth_creds)
self.assertTrue(self.yt_alt_oauth.is_alt_oauth)
self.assertEqual(self.yt_alt_oauth.auth_type, AuthType.OAUTH_CUSTOM_CLIENT)
###############
# BROWSING