@@ -126,96 +126,20 @@ def test_deploy_as_static_space_uploads_resolved_frontend(tmp_path, monkeypatch)
126126 ),
127127 )
128128
129- deploy .deploy_as_static_space (
130- "abidlabs/static-space" ,
131- None ,
132- "demo-project" ,
133- frontend_dir = frontend_dir ,
134- )
135-
136- assert any (
137- call ["folder_path" ] == str (frontend_dir ) for call in fake_api .uploaded_folders
138- )
139-
140-
141- def test_deploy_as_static_space_does_not_embed_hf_token (tmp_path , monkeypatch ):
142- frontend_dir = tmp_path / "custom-static"
143- frontend_dir .mkdir ()
144- (frontend_dir / "index.html" ).write_text ("<!doctype html>" )
145-
146- fake_api = _FakeHfApi ()
147- monkeypatch .setattr (deploy .huggingface_hub , "HfApi" , lambda : fake_api )
148- monkeypatch .setattr (deploy .huggingface_hub , "create_repo" , lambda * a , ** k : None )
149- monkeypatch .setattr (
150- deploy ,
151- "resolve_frontend_dir" ,
152- lambda frontend_dir = None , announce = False : ResolvedFrontend (
153- path = frontend_dir .resolve (),
154- source = "argument" ,
155- is_custom = True ,
156- ),
157- )
158-
159- deploy .deploy_as_static_space (
160- "abidlabs/static-space" ,
161- None ,
162- "demo-project" ,
163- bucket_id = "abidlabs/static-bucket" ,
164- private = False ,
165- hf_token = "hf_should_not_be_serialized" ,
166- frontend_dir = frontend_dir ,
167- )
168-
169- config_upload = next (
170- item for item in fake_api .uploaded_files if item ["path_in_repo" ] == "config.json"
171- )
172- config = json .loads (config_upload ["payload" ])
173- assert "hf_token" not in config
174-
175-
176- def test_deploy_as_static_space_rejects_private (monkeypatch ):
177- monkeypatch .setattr (
178- deploy .huggingface_hub ,
179- "HfApi" ,
180- lambda : pytest .fail ("HfApi should not be constructed" ),
181- )
182-
183- with pytest .raises (ValueError , match = "private static Trackio Space" ):
129+ with pytest .warns (UserWarning , match = "private=True is ignored" ):
184130 deploy .deploy_as_static_space (
185131 "abidlabs/static-space" ,
186132 None ,
187133 "demo-project" ,
188134 private = True ,
189- hf_token = "hf_should_not_be_used" ,
135+ frontend_dir = frontend_dir ,
190136 )
191137
192-
193- def test_sync_static_rejects_private_before_network (monkeypatch ):
194- monkeypatch .setattr (
195- deploy .huggingface_hub ,
196- "HfApi" ,
197- lambda : pytest .fail ("HfApi should not be constructed" ),
138+ assert any (
139+ call ["folder_path" ] == str (frontend_dir ) for call in fake_api .uploaded_folders
198140 )
199-
200- with pytest .raises (ValueError , match = "private static Trackio Space" ):
201- deploy .sync (
202- project = "demo-project" ,
203- space_id = "abidlabs/static-space" ,
204- sdk = "static" ,
205- private = True ,
206- )
207-
208-
209- def test_freeze_rejects_private_before_network (monkeypatch ):
210- monkeypatch .setattr (
211- deploy .huggingface_hub ,
212- "HfApi" ,
213- lambda : pytest .fail ("HfApi should not be constructed" ),
141+ config_upload = next (
142+ item for item in fake_api .uploaded_files if item ["path_in_repo" ] == "config.json"
214143 )
215-
216- with pytest .raises (ValueError , match = "private static Trackio Space" ):
217- deploy .freeze (
218- space_id = "abidlabs/source-space" ,
219- project = "demo-project" ,
220- private = True ,
221- )
144+ config = json .loads (config_upload ["payload" ])
145+ assert config ["private" ] is False
0 commit comments