本文整理汇总了Python中synapseclient.File.foo方法的典型用法代码示例。如果您正苦于以下问题:Python File.foo方法的具体用法?Python File.foo怎么用?Python File.foo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类synapseclient.File
的用法示例。
在下文中一共展示了File.foo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_and_store
# 需要导入模块: from synapseclient import File [as 别名]
# 或者: from synapseclient.File import foo [as 别名]
def test_get_and_store():
"""Test synapse.get and synapse.store in Project, Folder and File"""
## create project
project = Project(name=str(uuid.uuid4()), description='A bogus test project')
project = syn.store(project)
schedule_for_cleanup(project)
## create folder
folder = Folder('Bad stuff', parent=project, description='The rejects from the other fauxldurr', pi=3)
folder = syn.store(folder)
## get folder
folder = syn.get(folder.id)
assert folder.name == 'Bad stuff'
assert folder.parentId == project.id
assert folder.description == 'The rejects from the other fauxldurr'
assert folder.pi[0] == 3
## update folder
folder.pi = 3.14159265359
folder.description = 'The rejects from the other folder'
syn.store(folder)
## verify that the updates stuck
folder = syn.get(folder)
assert folder.name == 'Bad stuff'
assert folder.parentId == project.id
assert folder.description == 'The rejects from the other folder'
assert folder.pi[0] == 3.14159265359
## upload a File
path = utils.make_bogus_data_file()
schedule_for_cleanup(path)
random_data = File(path, parent=folder, description='Random data', foo=9844)
random_data = syn.store(random_data)
## make sure file comes back intact
random_data_2 = syn.downloadEntity(random_data)
assert filecmp.cmp(path, random_data_2.path)
assert random_data.foo[0] == 9844
## update with a new File
new_file_path = utils.make_bogus_data_file()
schedule_for_cleanup(new_file_path)
random_data.path = new_file_path
random_data.foo = 1266
random_data = syn.store(random_data)
## should be version 2
assert random_data.versionNumber == 2
## make sure the updates stuck
random_data_2 = syn.get(random_data)
assert random_data_2.path is not None
assert filecmp.cmp(new_file_path, random_data_2.path)
assert random_data_2.foo[0] == 1266
assert random_data_2.versionNumber == 2
## make sure we can still get the older version of file
old_random_data = syn.get(random_data.id, version=1)
assert filecmp.cmp(old_random_data.path, path)