本文整理汇总了Python中app.models.project.Project.process_attachments方法的典型用法代码示例。如果您正苦于以下问题:Python Project.process_attachments方法的具体用法?Python Project.process_attachments怎么用?Python Project.process_attachments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.project.Project
的用法示例。
在下文中一共展示了Project.process_attachments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProjectTest
# 需要导入模块: from app.models.project import Project [as 别名]
# 或者: from app.models.project.Project import process_attachments [as 别名]
class ProjectTest(AppCase):
def setUp(self):
self.setup_app()
self.create_user()
self.create_issue()
self.project = Project(
name='foo bar',
repo='foo/bar',
author=self.test_user
)
self.project.issues.append(self.test_issue)
self.project.save()
self.test_issue.project = self.project
self.test_issue.save()
def tearDown(self):
self.teardown_dbs()
def test_process_attachments(self):
file = MagicMock()
file.filename = 'foo.jpg'
files = {'file0': file }
self.project.upload_file = MagicMock(return_value='12345')
self.project.process_attachments(files, self.test_issue)
attachment = self.project.attachments[0]
self.assertEqual(attachment.file_id, '12345')
self.assertEqual(attachment.project, self.project)
self.assertEqual(attachment.parent, self.test_issue)
def test_process_attachments_disallowed_extension(self):
file = MagicMock()
file.filename = 'foo.sh'
files = {'file0': file }
self.project.process_attachments(files, self.test_issue)
self.assertEqual(len(self.project.attachments), 0)
def test_pre_delete(self):
self.assertEqual(Issue.objects.count(), 1)
self.project.delete()
self.assertEqual(Issue.objects.count(), 0)