File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 2121import unittest
2222from io import BytesIO
2323
24+ import requests
2425from huggingface_hub .constants import REPO_TYPE_DATASET , REPO_TYPE_SPACE
2526from huggingface_hub .file_download import cached_download
2627from huggingface_hub .hf_api import (
@@ -434,6 +435,25 @@ def test_dataset_info(self):
434435 self .assertEqual (dataset .sha , DUMMY_DATASET_ID_REVISION_ONE_SPECIFIC_COMMIT )
435436
436437
438+ class HfApiPrivateTest (HfApiCommonTestWithLogin ):
439+ def setUp (self ) -> None :
440+ super ().setUp ()
441+ self ._api .create_repo (token = self ._token , name = REPO_NAME , private = True )
442+
443+ def tearDown (self ) -> None :
444+ self ._api .delete_repo (token = self ._token , name = REPO_NAME )
445+
446+ def test_model_info (self ):
447+ # Test we cannot access model info without a token
448+ with self .assertRaisesRegex (requests .exceptions .HTTPError , "404 Client Error" ):
449+ _ = self ._api .model_info (repo_id = f"{ USER } /{ REPO_NAME } " )
450+ # Test we can access model info with a token
451+ model_info = self ._api .model_info (
452+ repo_id = f"{ USER } /{ REPO_NAME } " , token = self ._token
453+ )
454+ self .assertIsInstance (model_info , ModelInfo )
455+
456+
437457class HfFolderTest (unittest .TestCase ):
438458 def test_token_workflow (self ):
439459 """
You can’t perform that action at this time.
0 commit comments