当前位置: 首页>>代码示例>>Python>>正文


Python Project.delete方法代码示例

本文整理汇总了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()
开发者ID:doanac,项目名称:patchwork,代码行数:62,代码来源:test_patchparser.py

示例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()
开发者ID:anderco,项目名称:patchwork,代码行数:29,代码来源:test_patchparser.py

示例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()
开发者ID:anderco,项目名称:patchwork,代码行数:51,代码来源:test_patchparser.py

示例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()
开发者ID:deenseth,项目名称:patchwork,代码行数:50,代码来源:patchparser.py

示例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()
开发者ID:anderco,项目名称:patchwork,代码行数:47,代码来源:test_patchparser.py

示例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()
开发者ID:doanac,项目名称:patchwork,代码行数:41,代码来源:test_patchparser.py

示例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()
开发者ID:deenseth,项目名称:patchwork,代码行数:40,代码来源:patchparser.py


注:本文中的patchwork.models.Project.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。