本文整理汇总了Python中addons.osfstorage.models.OsfStorageFile.save方法的典型用法代码示例。如果您正苦于以下问题:Python OsfStorageFile.save方法的具体用法?Python OsfStorageFile.save怎么用?Python OsfStorageFile.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类addons.osfstorage.models.OsfStorageFile
的用法示例。
在下文中一共展示了OsfStorageFile.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_file_guids_trashed_file_wo_guid
# 需要导入模块: from addons.osfstorage.models import OsfStorageFile [as 别名]
# 或者: from addons.osfstorage.models.OsfStorageFile import save [as 别名]
def test_get_file_guids_trashed_file_wo_guid(self):
node = self.node_settings.owner
file = OsfStorageFile(name='foo', node=node)
file.save()
file.delete()
assert [] == OsfStorageFileNode.get_file_guids(
'/' + file._id, provider='osfstorage', node=node)
示例2: test_get_file_guids_for_live_file
# 需要导入模块: from addons.osfstorage.models import OsfStorageFile [as 别名]
# 或者: from addons.osfstorage.models.OsfStorageFile import save [as 别名]
def test_get_file_guids_for_live_file(self):
node = self.node_settings.owner
file = OsfStorageFile(name='foo', node=node)
file.save()
file.get_guid(create=True)
guid = file.get_guid()._id
assert guid is not None
assert guid in OsfStorageFileNode.get_file_guids(
'/' + file._id, provider='osfstorage', node=node)
示例3: test_serialize
# 需要导入模块: from addons.osfstorage.models import OsfStorageFile [as 别名]
# 或者: from addons.osfstorage.models.OsfStorageFile import save [as 别名]
def test_serialize(self):
file = OsfStorageFile(name='MOAR PYLONS', node=self.node_settings.owner)
file.save()
assert_equals(file.serialize(), {
u'id': file._id,
u'path': file.path,
u'created': None,
u'name': u'MOAR PYLONS',
u'kind': 'file',
u'version': 0,
u'downloads': 0,
u'size': None,
u'modified': None,
u'contentType': None,
u'checkout': None,
u'md5': None,
u'sha256': None,
})
version = file.create_version(
self.user,
{
u'service': u'cloud',
settings.WATERBUTLER_RESOURCE: u'osf',
u'object': u'06d80e',
}, {
u'size': 1234,
u'contentType': u'text/plain'
})
assert_equals(file.serialize(), {
u'id': file._id,
u'path': file.path,
u'created': version.date_created.isoformat(),
u'name': u'MOAR PYLONS',
u'kind': u'file',
u'version': 1,
u'downloads': 0,
u'size': 1234L,
u'modified': version.date_created.isoformat(),
u'contentType': u'text/plain',
u'checkout': None,
u'md5': None,
u'sha256': None,
})
示例4: test_file_path
# 需要导入模块: from addons.osfstorage.models import OsfStorageFile [as 别名]
# 或者: from addons.osfstorage.models.OsfStorageFile import save [as 别名]
def test_file_path(self):
file = OsfStorageFile(name='MOAR PYLONS', node=self.node)
file.save()
assert_equal(file.name, 'MOAR PYLONS')
assert_equal(file.path, '/{}'.format(file._id))