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
示例#2
0
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()
示例#3
0
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()
示例#4
0
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()
示例#5
0
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()
示例#6
0
def test_create_without_data():
    f = File.create_without_data(123)
    assert f.id == 123
示例#7
0
def test_create_without_data():  # type: () -> None
    f = File.create_without_data('a123')
    assert f.id == 'a123'
示例#8
0
def test_create_without_data():
    f = File.create_without_data(123)
    assert f.id == 123
示例#9
0
def test_create_without_data():  # type: () -> None
    f = File.create_without_data('a123')
    assert f.id == 'a123'