MCPcopy Create free account
hub / github.com/modelscope/modelscope / test_http_storage

Method test_http_storage

tests/fileio/test_file.py:43–58  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

41 os.remove(temp_name)
42
43 def test_http_storage(self):
44 storage = HTTPStorage()
45 url = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/texts/data.txt'
46 content = 'this is test data'
47 self.assertEqual(content.encode('utf8'), storage.read(url))
48 self.assertEqual(content, storage.read_text(url))
49
50 with storage.as_local_path(url) as local_file:
51 with open(local_file, 'r') as infile:
52 self.assertEqual(content, infile.read())
53
54 with self.assertRaises(NotImplementedError):
55 storage.write('dfad', url)
56
57 with self.assertRaises(HTTPError):
58 storage.read(url + 'df')
59
60 def test_file(self):
61 url = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/texts/data.txt'

Callers

nothing calls this directly

Calls 7

readMethod · 0.95
read_textMethod · 0.95
as_local_pathMethod · 0.95
writeMethod · 0.95
HTTPStorageClass · 0.90
encodeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected