Skip to content

Commit 5cc812f

Browse files
Update tests following server-side changes (#3181)
* update tests * nit
1 parent eebd13d commit 5cc812f

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

tests/test_file_download.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
DUMMY_EXTRA_LARGE_FILE_NAME,
5353
DUMMY_MODEL_ID,
5454
DUMMY_MODEL_ID_REVISION_ONE_SPECIFIC_COMMIT,
55-
DUMMY_RENAMED_NEW_MODEL_ID,
5655
DUMMY_RENAMED_OLD_MODEL_ID,
5756
DUMMY_TINY_FILE_NAME,
5857
SAMPLE_DATASET_IDENTIFIER,
@@ -318,7 +317,7 @@ def _check_user_agent(headers: dict):
318317
user_agent="foo/bar",
319318
)
320319
calls = mock_request.call_args_list
321-
assert len(calls) == 3 # HEAD, HEAD, GET
320+
assert len(calls) >= 3 # at least HEAD, HEAD, GET
322321
for call in calls:
323322
_check_user_agent(call.kwargs["headers"])
324323

@@ -333,7 +332,7 @@ def _check_user_agent(headers: dict):
333332
user_agent="foo/bar",
334333
)
335334
calls = mock_request.call_args_list
336-
assert len(calls) == 2 # HEAD, HEAD
335+
assert len(calls) >= 2 # at least HEAD, HEAD
337336
for call in calls:
338337
_check_user_agent(call.kwargs["headers"])
339338

@@ -482,24 +481,8 @@ def test_get_hf_file_metadata_basic(self) -> None:
482481
# Metadata
483482
self.assertEqual(metadata.commit_hash, DUMMY_MODEL_ID_REVISION_ONE_SPECIFIC_COMMIT)
484483
self.assertIsNotNone(metadata.etag) # example: "85c2fc2dcdd86563aaa85ef4911..."
485-
self.assertEqual(metadata.location, url) # no redirect
486484
self.assertEqual(metadata.size, 851)
487485

488-
def test_get_hf_file_metadata_from_a_renamed_repo(self) -> None:
489-
"""Test getting metadata from a file in a renamed repo on the Hub."""
490-
url = hf_hub_url(
491-
DUMMY_RENAMED_OLD_MODEL_ID,
492-
filename=constants.CONFIG_NAME,
493-
subfolder="", # Subfolder should be processed as `None`
494-
)
495-
metadata = get_hf_file_metadata(url)
496-
497-
# Got redirected to renamed repo
498-
self.assertEqual(
499-
metadata.location,
500-
url.replace(DUMMY_RENAMED_OLD_MODEL_ID, DUMMY_RENAMED_NEW_MODEL_ID),
501-
)
502-
503486
def test_get_hf_file_metadata_from_a_lfs_file(self) -> None:
504487
"""Test getting metadata from an LFS file.
505488

0 commit comments

Comments
 (0)