Image21-INT8 / tests /test_upload_auth.py
ixim's picture
Release verified Image21-INT8 conversion
6f8c80a verified
Raw History Blame Contribute Delete
858 Bytes
import os
import unittest
from unittest.mock import patch
from scripts.upload import modelscope_access
class CachedGitOnly:
@staticmethod
def get_token():
return 'cached-git-credential-not-an-api-token'
@staticmethod
def get_cookies():
return None
class UploadAuthTests(unittest.TestCase):
def test_cached_git_credential_cannot_authorize_api_upload(self):
with patch.dict(os.environ, {}, clear=True):
with self.assertRaisesRegex(RuntimeError, 'API'):
modelscope_access(CachedGitOnly, 'iximbox')
def test_explicit_sdk_token_is_selected(self):
with patch.dict(os.environ, {'MODELSCOPE_API_TOKEN': 'test-sdk-token'}, clear=True):
self.assertEqual(modelscope_access(CachedGitOnly, 'iximbox'), 'test-sdk-token')
if __name__ == '__main__':
unittest.main()