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


Python Project.save方法代码示例

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


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

示例1: InitialPatchStateTest

# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import save [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 save [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: test_get_numeric_linkname

# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import save [as 别名]
    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,代码行数:11,代码来源:test_rest_api.py

示例4: setUp

# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import save [as 别名]
 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,代码行数:13,代码来源:test_tags.py

示例5: ListIdHeaderTest

# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import save [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

示例6: create_project

# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import save [as 别名]
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,代码行数:17,代码来源:utils.py

示例7: ListIdHeaderTest

# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import save [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

示例8: DelegateRequestTest

# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import save [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

示例9: MultipleProjectPatchTest

# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import save [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

示例10: MultipleProjectPatchTest

# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import save [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

示例11: MultipleProjectsPerMailingListTest

# 需要导入模块: from patchwork.models import Project [as 别名]
# 或者: from patchwork.models.Project import save [as 别名]
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,代码行数:79,代码来源:test_patchparser.py


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