本文整理汇总了Python中patchwork.models.Project.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Project.delete方法的具体用法?Python Project.delete怎么用?Python Project.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类patchwork.models.Project
的用法示例。
在下文中一共展示了Project.delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InitialPatchStateTest
# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import delete [as 别名]
class InitialPatchStateTest(TestCase):
fixtures = ['default_states']
patch_filename = '0001-add-line.patch'
msgid = '<[email protected]>'
invalid_state_name = "Nonexistent Test State"
def setUp(self):
self.patch = read_patch(self.patch_filename)
self.user = create_user()
self.p1 = Project(linkname='test-project-1', name='Project 1',
listid='1.example.com', listemail='[email protected]')
self.p1.save()
self.default_state = get_default_initial_patch_state()
self.nondefault_state = State.objects.get(name="Accepted")
def get_email(self):
email = create_email(self.patch)
del email['List-ID']
email['List-ID'] = '<' + self.p1.listid + '>'
email['Message-Id'] = self.msgid
return email
def _assertState(self, state):
query = Patch.objects.filter(project=self.p1)
self.assertEqual(query.count(), 1)
self.assertEqual(query[0].state, state)
def testNonDefaultStateIsActuallyNotTheDefaultState(self):
self.assertNotEqual(self.default_state, self.nondefault_state)
def testExplicitNonDefaultStateRequest(self):
email = self.get_email()
email['X-Patchwork-State'] = self.nondefault_state.name
parse_mail(email)
self._assertState(self.nondefault_state)
def testExplicitDefaultStateRequest(self):
email = self.get_email()
email['X-Patchwork-State'] = self.default_state.name
parse_mail(email)
self._assertState(self.default_state)
def testImplicitDefaultStateRequest(self):
email = self.get_email()
parse_mail(email)
self._assertState(self.default_state)
def testInvalidTestStateDoesNotExist(self):
with self.assertRaises(State.DoesNotExist):
State.objects.get(name=self.invalid_state_name)
def testInvalidStateRequestFallsBackToDefaultState(self):
email = self.get_email()
email['X-Patchwork-State'] = self.invalid_state_name
parse_mail(email)
self._assertState(self.default_state)
def tearDown(self):
self.p1.delete()
self.user.delete()
示例2: MailFromPatchTest
# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import delete [as 别名]
class MailFromPatchTest(TestCase):
fixtures = ['default_states', 'default_events']
patch_filename = '0001-add-line.patch'
msgid = '<[email protected]>'
def get_email(self, multipart=False):
if multipart:
email = create_email('See attached patch!', multipart=multipart)
attachment = MIMEText(self.patch, _subtype='x-patch')
email.attach(attachment)
else:
email = create_email(self.patch)
del email['List-ID']
email['List-ID'] = '<' + self.p1.listid + '>'
email['Message-Id'] = self.msgid
return email
def setUp(self):
self.patch = read_patch(self.patch_filename)
self.user = create_user()
self.p1 = Project(linkname='test-project-1', name='Project 1',
listid='1.example.com', listemail='[email protected]')
self.p1.save()
def tearDown(self):
self.p1.delete()
self.user.delete()
示例3: ListIdHeaderTest
# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import delete [as 别名]
class ListIdHeaderTest(TestCase):
"""Test that we parse List-Id headers from mails correctly."""
def setUp(self):
self.project = Project(linkname='test-project-1', name='Project 1',
listid='1.example.com',
listemail='[email protected]')
self.project.save()
def testNoListId(self):
email = MIMEText('')
project = find_project(email)
self.assertEqual(project, None)
def testBlankListId(self):
email = MIMEText('')
email['List-Id'] = ''
project = find_project(email)
self.assertEqual(project, None)
def testWhitespaceListId(self):
email = MIMEText('')
email['List-Id'] = ' '
project = find_project(email)
self.assertEqual(project, None)
def testSubstringListId(self):
email = MIMEText('')
email['List-Id'] = 'example.com'
project = find_project(email)
self.assertEqual(project, None)
def testShortListId(self):
""" Some mailing lists have List-Id headers in short formats, where it
is only the list ID itself (without enclosing angle-brackets). """
email = MIMEText('')
email['List-Id'] = self.project.listid
project = find_project(email)
self.assertEqual(project, self.project)
def testLongListId(self):
email = MIMEText('')
email['List-Id'] = 'Test text <%s>' % self.project.listid
project = find_project(email)
self.assertEqual(project, self.project)
def tearDown(self):
self.project.delete()
示例4: ListIdHeaderTest
# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import delete [as 别名]
class ListIdHeaderTest(unittest.TestCase):
""" Test that we parse List-Id headers from mails correctly """
def setUp(self):
self.project = Project(
linkname="test-project-1", name="Project 1", listid="1.example.com", listemail="[email protected]"
)
self.project.save()
def testNoListId(self):
email = MIMEText("")
project = find_project(email)
self.assertEquals(project, None)
def testBlankListId(self):
email = MIMEText("")
email["List-Id"] = ""
project = find_project(email)
self.assertEquals(project, None)
def testWhitespaceListId(self):
email = MIMEText("")
email["List-Id"] = " "
project = find_project(email)
self.assertEquals(project, None)
def testSubstringListId(self):
email = MIMEText("")
email["List-Id"] = "example.com"
project = find_project(email)
self.assertEquals(project, None)
def testShortListId(self):
""" Some mailing lists have List-Id headers in short formats, where it
is only the list ID itself (without enclosing angle-brackets). """
email = MIMEText("")
email["List-Id"] = self.project.listid
project = find_project(email)
self.assertEquals(project, self.project)
def testLongListId(self):
email = MIMEText("")
email["List-Id"] = "Test text <%s>" % self.project.listid
project = find_project(email)
self.assertEquals(project, self.project)
def tearDown(self):
self.project.delete()
示例5: DelegateRequestTest
# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import delete [as 别名]
class DelegateRequestTest(TestCase):
fixtures = ['default_states', 'default_events']
patch_filename = '0001-add-line.patch'
msgid = '<[email protected]>'
invalid_delegate_email = "nobody"
def setUp(self):
self.patch = read_patch(self.patch_filename)
self.user = create_user()
self.p1 = Project(linkname='test-project-1', name='Project 1',
listid='1.example.com', listemail='[email protected]')
self.p1.save()
def get_email(self):
email = create_email(self.patch)
del email['List-ID']
email['List-ID'] = '<' + self.p1.listid + '>'
email['Message-Id'] = self.msgid
return email
def _assertDelegate(self, delegate):
query = Patch.objects.filter(project=self.p1)
self.assertEqual(query.count(), 1)
self.assertEqual(query[0].delegate, delegate)
def testDelegate(self):
email = self.get_email()
email['X-Patchwork-Delegate'] = self.user.email
parse_mail(email)
self._assertDelegate(self.user)
def testNoDelegate(self):
email = self.get_email()
parse_mail(email)
self._assertDelegate(None)
def testInvalidDelegateFallsBackToNoDelegate(self):
email = self.get_email()
email['X-Patchwork-Delegate'] = self.invalid_delegate_email
parse_mail(email)
self._assertDelegate(None)
def tearDown(self):
self.p1.delete()
self.user.delete()
示例6: MultipleProjectPatchTest
# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import delete [as 别名]
class MultipleProjectPatchTest(TestCase):
""" Test that patches sent to multiple patchwork projects are
handled correctly """
fixtures = ['default_states']
test_content = 'Test Comment'
patch_filename = '0001-add-line.patch'
msgid = '<[email protected]>'
def setUp(self):
self.p1 = Project(linkname='test-project-1', name='Project 1',
listid='1.example.com', listemail='[email protected]')
self.p2 = Project(linkname='test-project-2', name='Project 2',
listid='2.example.com', listemail='[email protected]')
self.p1.save()
self.p2.save()
patch = read_patch(self.patch_filename)
email = create_email(self.test_content + '\n' + patch)
del email['Message-Id']
email['Message-Id'] = self.msgid
del email['List-ID']
email['List-ID'] = '<' + self.p1.listid + '>'
parse_mail(email)
del email['List-ID']
email['List-ID'] = '<' + self.p2.listid + '>'
parse_mail(email)
def testParsedProjects(self):
self.assertEqual(Patch.objects.filter(project=self.p1).count(), 1)
self.assertEqual(Patch.objects.filter(project=self.p2).count(), 1)
def tearDown(self):
self.p1.delete()
self.p2.delete()
示例7: MultipleProjectPatchTest
# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import delete [as 别名]
class MultipleProjectPatchTest(unittest.TestCase):
""" Test that patches sent to multiple patchwork projects are
handled correctly """
test_comment = "Test Comment"
patch_filename = "0001-add-line.patch"
msgid = "<[email protected]>"
def setUp(self):
self.p1 = Project(
linkname="test-project-1", name="Project 1", listid="1.example.com", listemail="[email protected]"
)
self.p2 = Project(
linkname="test-project-2", name="Project 2", listid="2.example.com", listemail="[email protected]"
)
self.p1.save()
self.p2.save()
patch = read_patch(self.patch_filename)
email = create_email(self.test_comment + "\n" + patch)
email["Message-Id"] = self.msgid
del email["List-ID"]
email["List-ID"] = "<" + self.p1.listid + ">"
parse_mail(email)
del email["List-ID"]
email["List-ID"] = "<" + self.p2.listid + ">"
parse_mail(email)
def testParsedProjects(self):
self.assertEquals(Patch.objects.filter(project=self.p1).count(), 1)
self.assertEquals(Patch.objects.filter(project=self.p2).count(), 1)
def tearDown(self):
self.p1.delete()
self.p2.delete()