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


Python models.Project类代码示例

本文整理汇总了Python中patchwork.models.Project的典型用法代码示例。如果您正苦于以下问题:Python Project类的具体用法?Python Project怎么用?Python Project使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: InitialPatchStateTest

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,代码行数:60,代码来源:test_patchparser.py

示例2: MailFromPatchTest

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,代码行数:27,代码来源:test_patchparser.py

示例3: setUp

 def setUp(self):
     self.project1 = Project(linkname='test-project-1', name='Project 1',
             listid='list.example.com', listemail='[email protected]')
     self.project1.save()
     self.project2 = Project(linkname='test-project-2', name='Project 2',
             listid='list.example.com', listemail='[email protected]')
     self.project2.save()
开发者ID:lsandoval,项目名称:patchwork,代码行数:7,代码来源:test_patchparser.py

示例4: test_get_numeric_linkname

    def test_get_numeric_linkname(self):
        """Validate we try to do the right thing for numeric linkname"""
        project = Project(linkname='12345', name='Test Project',
                          listid='test.example.com')
        project.save()

        resp = self.client.get(self.api_url('12345'))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(project.name, resp.data['name'])
开发者ID:nickglobal,项目名称:patchwork,代码行数:9,代码来源:test_rest_api.py

示例5: setUp

 def setUp(self):
     project = Project(linkname='test-project', name='Test Project',
                       use_tags=True)
     project.save()
     defaults.patch_author_person.save()
     self.patch = Patch(project=project,
                        msgid='x', name=defaults.patch_name,
                        submitter=defaults.patch_author_person,
                        content='')
     self.patch.save()
     self.tagger = 'Test Tagger <[email protected]>'
开发者ID:anderco,项目名称:patchwork,代码行数:11,代码来源:test_tags.py

示例6: ListIdHeaderTest

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,代码行数:49,代码来源:test_patchparser.py

示例7: create_project

def create_project(**kwargs):
    """Create a 'Project' object."""
    num = Project.objects.count()

    values = {
        'linkname': 'test-project-%d' % num,
        'name': 'Test Project %d' % num,
        'listid': 'test%d.example.com' % num,
    }
    values.update(kwargs)

    project = Project(**values)
    project.save()

    return project
开发者ID:nickglobal,项目名称:patchwork,代码行数:15,代码来源:utils.py

示例8: ListIdHeaderTest

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,代码行数:48,代码来源:patchparser.py

示例9: setUp

 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")
开发者ID:tklengyel,项目名称:patchwork,代码行数:8,代码来源:test_patchparser.py

示例10: DelegateRequestTest

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,代码行数:45,代码来源:test_patchparser.py

示例11: setUp

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

示例12: MultipleProjectPatchTest

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,代码行数:39,代码来源:test_patchparser.py

示例13: MultipleProjectPatchTest

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,代码行数:38,代码来源:patchparser.py

示例14: setUp

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

示例15: MultipleProjectsPerMailingListTest

class MultipleProjectsPerMailingListTest(TestCase):
    """Do we handle hosting multiple projects on the same mailing-list?"""
    fixtures = ['default_states', 'default_events']

    def setUp(self):
        self.project1 = Project(linkname='test-project-1', name='Project 1',
                                listid='list.example.com',
                                listemail='[email protected]')
        self.project1.save()
        self.project2 = Project(linkname='test-project-2', name='Project 2',
                                listid='list.example.com',
                                listemail='[email protected]')
        self.project2.save()

    def testTagList(self):
        self.project1.subject_prefix_tags = ''
        self.assertEquals(self.project1.get_subject_prefix_tags(), [])

        self.project1.subject_prefix_tags = ' '
        self.assertEquals(self.project1.get_subject_prefix_tags(), [])

        self.project1.subject_prefix_tags = 'i-g-t'
        self.assertEquals(self.project1.get_subject_prefix_tags(), ['i-g-t'])

        self.project1.subject_prefix_tags = 'a,b'
        self.assertEquals(self.project1.get_subject_prefix_tags(), ['a', 'b'])

        self.project1.subject_prefix_tags = 'a, ,b,'
        self.assertEquals(self.project1.get_subject_prefix_tags(), ['a', 'b'])

    def testSingleTag(self):
        self.project2.subject_prefix_tags = 'i-g-t'
        self.project2.save()

        email = create_email(defaults.patch, project=self.project1,
                             subject='[PATCH] Subject')
        self.assertEquals(find_project(email), self.project1)
        email = create_email(defaults.patch, project=self.project1,
                             subject='[PATCH i-g-t] Subject')
        self.assertEquals(find_project(email), self.project2)

    def testSingleTagInverted(self):
        """To test the order_by()"""
        self.project1.subject_prefix_tags = 'i-g-t'
        self.project1.save()
        self.project2.subject_prefix_tags = ' '
        self.project2.save()

        email = create_email(defaults.patch, project=self.project1,
                             subject='[PATCH i-g-t] Subject')
        self.assertEquals(find_project(email), self.project1)
        email = create_email(defaults.patch, project=self.project1,
                             subject='[PATCH] Subject')
        self.assertEquals(find_project(email), self.project2)

    def testMultipleTags(self):
        self.project2.subject_prefix_tags = 'i-g-t,intel-gpu-tools'
        self.project2.save()

        email = create_email(defaults.patch, project=self.project1,
                             subject='[PATCH] Subject')
        self.assertEquals(find_project(email), self.project1)
        email = create_email(defaults.patch, project=self.project1,
                             subject='[PATCH i-g-t] Subject')
        self.assertEquals(find_project(email), self.project2)
        email = create_email(defaults.patch, project=self.project1,
                             subject='[PATCH intel-gpu-tools] Subject')
        self.assertEquals(find_project(email), self.project2)

    def testStripTag(self):
        self.project2.subject_prefix_tags = 'i-g-t'
        self.project2.save()
        email = create_email(defaults.patch, project=self.project1,
                             subject='[PATCH i-g-t] Subject')
        parse_mail(email)
        patch = Patch.objects.all()[0]
        self.assertEquals(patch.name, 'Subject')
开发者ID:anderco,项目名称:patchwork,代码行数:77,代码来源:test_patchparser.py


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