2020import types
2121import unittest
2222import uuid
23- import warnings
2423from collections .abc import Iterable
2524from concurrent .futures import Future
2625from dataclasses import fields
9392 DUMMY_MODEL_ID_REVISION_ONE_SPECIFIC_COMMIT ,
9493 ENDPOINT_PRODUCTION ,
9594 SAMPLE_DATASET_IDENTIFIER ,
95+ expect_deprecation ,
9696 repo_name ,
9797 require_git_lfs ,
9898 rmtree_with_retry ,
@@ -124,18 +124,6 @@ def setUpClass(cls):
124124 cls ._api = HfApi (endpoint = ENDPOINT_STAGING , token = TOKEN )
125125
126126
127- def test_repo_id_no_warning ():
128- # tests that passing repo_id as positional arg doesn't raise any warnings
129- # for {create, delete}_repo and update_repo_visibility
130- api = HfApi (endpoint = ENDPOINT_STAGING , token = TOKEN )
131-
132- with warnings .catch_warnings (record = True ) as record :
133- repo_id = api .create_repo (repo_name ()).repo_id
134- api .update_repo_visibility (repo_id , private = True )
135- api .delete_repo (repo_id )
136- assert not len (record )
137-
138-
139127class HfApiRepoFileExistsTest (HfApiCommonTest ):
140128 def setUp (self ) -> None :
141129 super ().setUp ()
@@ -210,6 +198,7 @@ def test_delete_repo_error_message(self):
210198 def test_delete_repo_missing_ok (self ) -> None :
211199 self ._api .delete_repo ("repo-that-does-not-exist" , missing_ok = True )
212200
201+ @expect_deprecation ("update_repo_visibility" )
213202 def test_create_update_and_delete_repo (self ):
214203 repo_id = self ._api .create_repo (repo_id = repo_name ()).repo_id
215204 res = self ._api .update_repo_visibility (repo_id = repo_id , private = True )
@@ -218,6 +207,7 @@ def test_create_update_and_delete_repo(self):
218207 assert not res ["private" ]
219208 self ._api .delete_repo (repo_id = repo_id )
220209
210+ @expect_deprecation ("update_repo_visibility" )
221211 def test_create_update_and_delete_model_repo (self ):
222212 repo_id = self ._api .create_repo (repo_id = repo_name (), repo_type = constants .REPO_TYPE_MODEL ).repo_id
223213 res = self ._api .update_repo_visibility (repo_id = repo_id , private = True , repo_type = constants .REPO_TYPE_MODEL )
@@ -226,6 +216,7 @@ def test_create_update_and_delete_model_repo(self):
226216 assert not res ["private" ]
227217 self ._api .delete_repo (repo_id = repo_id , repo_type = constants .REPO_TYPE_MODEL )
228218
219+ @expect_deprecation ("update_repo_visibility" )
229220 def test_create_update_and_delete_dataset_repo (self ):
230221 repo_id = self ._api .create_repo (repo_id = repo_name (), repo_type = constants .REPO_TYPE_DATASET ).repo_id
231222 res = self ._api .update_repo_visibility (repo_id = repo_id , private = True , repo_type = constants .REPO_TYPE_DATASET )
@@ -234,6 +225,7 @@ def test_create_update_and_delete_dataset_repo(self):
234225 assert not res ["private" ]
235226 self ._api .delete_repo (repo_id = repo_id , repo_type = constants .REPO_TYPE_DATASET )
236227
228+ @expect_deprecation ("update_repo_visibility" )
237229 def test_create_update_and_delete_space_repo (self ):
238230 with pytest .raises (ValueError , match = r"No space_sdk provided.*" ):
239231 self ._api .create_repo (repo_id = repo_name (), repo_type = constants .REPO_TYPE_SPACE , space_sdk = None )
@@ -286,19 +278,25 @@ def test_update_repo_settings(self, repo_url: RepoUrl):
286278 repo_id = repo_url .repo_id
287279
288280 for gated_value in ["auto" , "manual" , False ]:
289- self ._api .update_repo_settings (repo_id = repo_id , gated = gated_value )
290- info = self ._api .model_info (repo_id , expand = "gated" )
291- assert info .gated == gated_value
281+ for private_value in [True , False ]: # Test both private and public settings
282+ self ._api .update_repo_settings (repo_id = repo_id , gated = gated_value , private = private_value )
283+ info = self ._api .model_info (repo_id )
284+ assert info .gated == gated_value
285+ assert info .private == private_value # Verify the private setting
292286
293287 @use_tmp_repo (repo_type = "dataset" )
294288 def test_update_dataset_repo_settings (self , repo_url : RepoUrl ):
295289 repo_id = repo_url .repo_id
296290 repo_type = repo_url .repo_type
297291
298292 for gated_value in ["auto" , "manual" , False ]:
299- self ._api .update_repo_settings (repo_id = repo_id , repo_type = repo_type , gated = gated_value )
300- info = self ._api .dataset_info (repo_id , expand = "gated" )
301- assert info .gated == gated_value
293+ for private_value in [True , False ]:
294+ self ._api .update_repo_settings (
295+ repo_id = repo_id , repo_type = repo_type , gated = gated_value , private = private_value
296+ )
297+ info = self ._api .dataset_info (repo_id )
298+ assert info .gated == gated_value
299+ assert info .private == private_value
302300
303301
304302class CommitApiTest (HfApiCommonTest ):
0 commit comments