fix tests
This commit is contained in:
parent
5e5daa3ae7
commit
e0d73c02b2
2 changed files with 7 additions and 8 deletions
|
|
@ -80,7 +80,6 @@ class TestYTMusic(unittest.TestCase):
|
||||||
###############
|
###############
|
||||||
# OAUTH
|
# OAUTH
|
||||||
###############
|
###############
|
||||||
# 000 so test is run first and fresh token is available to others
|
|
||||||
def test_oauth_tokens(self):
|
def test_oauth_tokens(self):
|
||||||
# ensure instance initialized token
|
# ensure instance initialized token
|
||||||
self.assertIsNotNone(self.yt_oauth._token)
|
self.assertIsNotNone(self.yt_oauth._token)
|
||||||
|
|
@ -90,16 +89,16 @@ class TestYTMusic(unittest.TestCase):
|
||||||
first_json = json.load(f)
|
first_json = json.load(f)
|
||||||
|
|
||||||
# pull reference values from underlying token
|
# pull reference values from underlying token
|
||||||
first_token = self.yt_oauth._token.token.access_token
|
first_token = self.yt_oauth._token.access_token
|
||||||
first_expire = self.yt_oauth._token.token.expires_at
|
first_expire = self.yt_oauth._token.expires_at
|
||||||
# make token expire
|
# make token expire
|
||||||
self.yt_oauth._token.token._expires_at = time.time()
|
self.yt_oauth._token.expires_at = time.time()
|
||||||
# check
|
# check
|
||||||
self.assertTrue(self.yt_oauth._token.token.is_expiring)
|
self.assertTrue(self.yt_oauth._token.is_expiring)
|
||||||
# pull new values, assuming token will be refreshed on access
|
# pull new values, assuming token will be refreshed on access
|
||||||
second_token = self.yt_oauth._token.access_token
|
second_token = self.yt_oauth._token.access_token
|
||||||
second_expire = self.yt_oauth._token.token.expires_at
|
second_expire = self.yt_oauth._token.expires_at
|
||||||
second_token_inner = self.yt_oauth._token.token.access_token
|
second_token_inner = self.yt_oauth._token.access_token
|
||||||
# check it was refreshed
|
# check it was refreshed
|
||||||
self.assertNotEqual(first_token, second_token)
|
self.assertNotEqual(first_token, second_token)
|
||||||
# check expiration timestamps to confirm
|
# check expiration timestamps to confirm
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ class RefreshingToken(OAuthToken):
|
||||||
#: protected/property attribute enables auto writing token values to new file location via setter
|
#: protected/property attribute enables auto writing token values to new file location via setter
|
||||||
_local_cache: Optional[str] = None
|
_local_cache: Optional[str] = None
|
||||||
|
|
||||||
def __getattr__(self, item):
|
def __getattribute__(self, item):
|
||||||
"""access token setter to auto-refresh if it is expiring"""
|
"""access token setter to auto-refresh if it is expiring"""
|
||||||
if item == "access_token" and self.is_expiring:
|
if item == "access_token" and self.is_expiring:
|
||||||
fresh = self.credentials.refresh_token(self.refresh_token)
|
fresh = self.credentials.refresh_token(self.refresh_token)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue