def test_lfs_object(self): url = hf_bucket_url(MODEL_ID, filename=WEIGHTS_NAME, revision=REVISION_ID_DEFAULT) filepath = get_from_cache(url, force_download=True) metadata = filename_to_url(filepath) self.assertEqual(metadata, (url, f'"{PINNED_SHA256}"'))
def test_revision_not_found(self): # Valid file but missing revision url = hf_bucket_url(MODEL_ID, filename=CONFIG_NAME, revision=REVISION_ID_INVALID) with self.assertRaisesRegex(RevisionNotFoundError, "404 Client Error"): _ = get_from_cache(url)
def test_standard_object_rev(self): # Same object, but different revision url = hf_bucket_url(MODEL_ID, filename=CONFIG_NAME, revision=REVISION_ID_ONE_SPECIFIC_COMMIT) filepath = get_from_cache(url, force_download=True) metadata = filename_to_url(filepath) self.assertNotEqual(metadata[1], f'"{PINNED_SHA1}"')
def test_model_not_found(self): # Invalid model file. url = hf_bucket_url("bert-base", filename="pytorch_model.bin") with self.assertRaisesRegex(RepositoryNotFoundError, "404 Client Error"): _ = get_from_cache(url)
def test_file_not_found(self): # Valid revision (None) but missing file. url = hf_bucket_url(MODEL_ID, filename="missing.bin") with self.assertRaisesRegex(EntryNotFoundError, "404 Client Error"): _ = get_from_cache(url)
def test_model_not_found_authenticated(self): # Invalid model id. url = hf_bucket_url("bert-base", filename="pytorch_model.bin") with self.assertRaisesRegex(RepositoryNotFoundError, "404 Client Error"): _ = get_from_cache(url, use_auth_token="hf_sometoken")