本文整理汇总了Python中tests.factories.ProjectFactory.remove_file方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectFactory.remove_file方法的具体用法?Python ProjectFactory.remove_file怎么用?Python ProjectFactory.remove_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.ProjectFactory
的用法示例。
在下文中一共展示了ProjectFactory.remove_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestFilesViews
# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import remove_file [as 别名]
#.........这里部分代码省略.........
assert_equal(data['urls']['latest']['download'], file_obj.download_url(self.project))
assert_equal(data['urls']['api'], file_obj.api_url(self.project))
version = res.json['versions'][0]
assert_equal(version['file_name'], self.fid)
assert_equal(version['version_number'], 2)
assert_equal(version['modified_date'], file_obj.date_uploaded.strftime('%Y/%m/%d %I:%M %p'))
assert_in('downloads', version)
assert_equal(version['committer_name'], file_obj.uploader.fullname)
assert_equal(version['committer_url'], file_obj.uploader.url)
def test_file_info_with_anonymous_link(self):
link = PrivateLinkFactory(anonymous=True)
link.nodes.append(self.project)
link.save()
self._upload_file('firstfile', 'secondcontent')
url = self.project.api_url_for(
'file_info', fid=self.project.uploads[0].filename
)
res = self.app.get(url, {'view_only': link.key})
assert_not_in(self.user.fullname, res.body)
assert_not_in(self.user._id, res.body)
def test_delete_file(self):
url = self.project.api_url_for('delete_file', fid=self.fid)
res = self.app.delete(url, auth=self.auth).maybe_follow()
assert_equal(res.status_code, 200)
self.project.reload()
assert_not_in('firstfile', self.project.files_current)
def test_delete_file_returns_404_when_file_is_already_deleted(self):
self.project.remove_file(Auth(self.project.creator), self.fid)
url = self.project.api_url_for('delete_file', fid=self.fid)
res = self.app.delete_json(url, auth=self.user.auth, expect_errors=True)
assert_equal(res.status_code, 404)
def test_file_urls(self):
url = self.project.api_url + 'osffiles/hgrid/'
res = self.app.get(url, auth=self.auth).maybe_follow()
assert_equal(len(res.json), 1)
for url in ['view', 'download', 'delete']:
assert_in(
self.project._id,
res.json[0]['urls'][url]
)
def test_file_urls_fork(self):
fork = self.project.fork_node(auth=Auth(user=self.user))
url = fork.api_url + 'osffiles/hgrid/'
res = self.app.get(url, auth=self.auth).maybe_follow()
assert_equal(len(res.json), 1)
for url in ['view', 'download', 'delete']:
assert_in(
fork._id,
res.json[0]['urls'][url]
)
def test_file_urls_registration(self):