當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。