def test_save_external(): # type: () -> None file_name = "lenna.jpg" file_url = "http://i1.wp.com/leancloud.cn/images/static/default-avatar.png" f = File.create_with_url(file_name, file_url) f.save() assert f.id file_on_cloud = File.create_without_data(f.id) file_on_cloud.fetch() assert file_on_cloud.name == file_name assert file_on_cloud.url == file_url
def test_fetch(): r = requests.get('http://i1.wp.com/leancloud.cn/images/static/default-avatar.png') b = buffer(r.content) f = File('Lenna2.jpg', b) f.metadata['foo'] = 'bar' f.save() fetched = File.create_without_data(f.id) fetched.fetch() assert fetched.id == f.id assert fetched.metadata == f.metadata assert fetched.name == f.name assert fetched.url == f.url assert fetched.size == f.size assert fetched.url == f.url f.destroy()
def test_fetch(): r = requests.get('http://i1.wp.com/leancloud.cn/images/static/default-avatar.png') b = buffer_type(r.content) f = File('Lenna2.jpg', b) f.metadata['foo'] = 'bar' f.save() fetched = File.create_without_data(f.id) fetched.fetch() assert fetched.id == f.id assert fetched.metadata == f.metadata assert fetched.name == f.name assert fetched.url == f.url assert fetched.size == f.size assert fetched.url == f.url f.destroy()
def test_fetch(): # type: () -> None r = requests.get("http://i1.wp.com/leancloud.cn/images/static/default-avatar.png") b = io.BytesIO(r.content) f = File("Lenna2.jpg", b) f.metadata["foo"] = "bar" f.save() fetched = File.create_without_data(f.id) fetched.fetch() normalized_f_url = f.url.split("/")[-1] normalized_fetched_url = f.url.split("/")[-1] assert fetched.id == f.id assert fetched.metadata == f.metadata assert fetched.name == f.name assert fetched.size == f.size assert fetched.url == f.url or normalized_fetched_url == normalized_f_url f.destroy()
def test_fetch(): # type: () -> None r = requests.get('http://i1.wp.com/leancloud.cn/images/static/default-avatar.png') b = io.BytesIO(r.content) f = File('Lenna2.jpg', b) f.metadata['foo'] = 'bar' f.save() fetched = File.create_without_data(f.id) fetched.fetch() normalized_f_url = f.url.split('/')[-1] normalized_fetched_url = f.url.split('/')[-1] assert fetched.id == f.id assert fetched.metadata == f.metadata assert fetched.name == f.name assert fetched.size == f.size assert fetched.url == f.url or normalized_fetched_url == normalized_f_url f.destroy()
def test_create_without_data(): f = File.create_without_data(123) assert f.id == 123
def test_create_without_data(): # type: () -> None f = File.create_without_data('a123') assert f.id == 'a123'