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


Python Patch.save方法代码示例

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


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

示例1: MboxPatchResponseTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
class MboxPatchResponseTest(TestCase):
    fixtures = ['default_states']

    """ Test that the mbox view appends the Acked-by from a patch comment """

    def setUp(self):
        defaults.project.save()

        self.person = defaults.patch_author_person
        self.person.save()

        self.patch = Patch(project=defaults.project,
                           msgid='p1', name='testpatch',
                           submitter=self.person, diff='',
                           content='comment 1 text\nAcked-by: 1\n')
        self.patch.save()

        comment = Comment(submission=self.patch,
                          msgid='p2',
                          submitter=self.person,
                          content='comment 2 text\nAcked-by: 2\n')
        comment.save()

    def testPatchResponse(self):
        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
        self.assertContains(response,
                            'Acked-by: 1\nAcked-by: 2\n')
开发者ID:doanac,项目名称:patchwork,代码行数:29,代码来源:test_mboxviews.py

示例2: MboxCommentPostcriptUnchangedTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
class MboxCommentPostcriptUnchangedTest(TestCase):
    """ Test that the mbox view doesn't change the postscript part of a mail.
        There where always a missing blank right after the postscript
        delimiter '---' and an additional newline right before. """
    def setUp(self):
        defaults.project.save()

        self.person = defaults.patch_author_person
        self.person.save()

        self.patch = Patch(project = defaults.project,
                           msgid = 'p1', name = 'testpatch',
                           submitter = self.person, content = '')
        self.patch.save()

        self.txt = 'some comment\n---\n some/file | 1 +\n'

        comment = Comment(patch = self.patch, msgid = 'p1',
                submitter = self.person,
                content = self.txt)
        comment.save()

    def testCommentUnchanged(self):
        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
        self.assertContains(response, self.txt)
        self.txt += "\n"
        self.assertNotContains(response, self.txt)
开发者ID:tklengyel,项目名称:patchwork,代码行数:29,代码来源:test_mboxviews.py

示例3: MboxDateHeaderTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
class MboxDateHeaderTest(TestCase):
    """ Test that the date provided in the patch mail view is correct """

    def setUp(self):
        defaults.project.save()
        self.person = defaults.patch_author_person
        self.person.save()

        self.patch = Patch(project = defaults.project,
                           msgid = 'p1', name = 'testpatch',
                           submitter = self.person, content = '')
        self.patch.save()

    def testDateHeader(self):
        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
        mail = email.message_from_string(response.content)
        mail_date = dateutil.parser.parse(mail['Date'])
        # patch dates are all in UTC
        patch_date = self.patch.date.replace(tzinfo=dateutil.tz.tzutc(),
                                            microsecond=0)
        self.assertEqual(mail_date, patch_date)

    def testSuppliedDateHeader(self):
        hour_offset = 3
        tz = dateutil.tz.tzoffset(None, hour_offset * 60 * 60)
        date = datetime.datetime.utcnow() - datetime.timedelta(days = 1)
        date = date.replace(tzinfo=tz, microsecond=0)

        self.patch.headers = 'Date: %s\n' % date.strftime("%a, %d %b %Y %T %z")
        self.patch.save()

        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
        mail = email.message_from_string(response.content)
        mail_date = dateutil.parser.parse(mail['Date'])
        self.assertEqual(mail_date, date)
开发者ID:tklengyel,项目名称:patchwork,代码行数:37,代码来源:test_mboxviews.py

示例4: _insert_patch

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
 def _insert_patch(self):
     patch = Patch(project=defaults.project,
                   submitter=defaults.patch_author_person,
                   msgid=defaults.patch_name,
                   content=defaults.patch)
     patch.save()
     return patch
开发者ID:asdil12,项目名称:patchwork,代码行数:9,代码来源:test_xmlrpc.py

示例5: MboxPatchSplitResponseTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
class MboxPatchSplitResponseTest(TestCase):
    """ Test that the mbox view appends the Acked-by from a patch comment,
        and places it before an '---' update line. """
    def setUp(self):
        defaults.project.save()

        self.person = defaults.patch_author_person
        self.person.save()

        self.patch = Patch(project = defaults.project,
                           msgid = 'p1', name = 'testpatch',
                           submitter = self.person, content = '')
        self.patch.save()
        comment = Comment(patch = self.patch, msgid = 'p1',
                submitter = self.person,
                content = 'comment 1 text\nAcked-by: 1\n---\nupdate\n')
        comment.save()

        comment = Comment(patch = self.patch, msgid = 'p2',
                submitter = self.person,
                content = 'comment 2 text\nAcked-by: 2\n')
        comment.save()

    def testPatchResponse(self):
        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
        self.assertContains(response,
                'Acked-by: 1\nAcked-by: 2\n')
开发者ID:tklengyel,项目名称:patchwork,代码行数:29,代码来源:test_mboxviews.py

示例6: MboxGeneratedHeaderTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
class MboxGeneratedHeaderTest(TestCase):
    fixtures = ['default_states']

    def setUp(self):
        defaults.project.save()
        self.person = defaults.patch_author_person
        self.person.save()

        self.user = create_user()

        self.patch = Patch(project=defaults.project,
                           msgid='p1',
                           name='testpatch',
                           submitter=self.person,
                           delegate=self.user,
                           content='')
        self.patch.save()

    def testPatchworkIdHeader(self):
        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
        self.assertContains(response, 'X-Patchwork-Id: %d' % self.patch.id)

    def testPatchworkDelegateHeader(self):
        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
        self.assertContains(response,
                            'X-Patchwork-Delegate: %s' % self.user.email)
开发者ID:doanac,项目名称:patchwork,代码行数:28,代码来源:test_mboxviews.py

示例7: MboxPassThroughHeaderTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
class MboxPassThroughHeaderTest(TestCase):
    """ Test that we see 'Cc' and 'To' headers passed through from original
        message to mbox view """

    def setUp(self):
        defaults.project.save()
        self.person = defaults.patch_author_person
        self.person.save()

        self.cc_header = 'Cc: CC Person <[email protected]>'
        self.to_header = 'To: To Person <[email protected]>'

        self.patch = Patch(project = defaults.project,
                           msgid = 'p1', name = 'testpatch',
                           submitter = self.person, content = '')

    def testCCHeader(self):
        self.patch.headers = self.cc_header + '\n'
        self.patch.save()

        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
        self.assertContains(response, self.cc_header)

    def testToHeader(self):
        self.patch.headers = self.to_header + '\n'
        self.patch.save()

        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
        self.assertContains(response, self.to_header)
开发者ID:asl,项目名称:llvm-patchwork,代码行数:31,代码来源:mboxviews.py

示例8: _insert_patch

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
 def _insert_patch(self):
     patch = Patch(project=defaults.project,
                   submitter=defaults.patch_author_person,
                   msgid=make_msgid(),
                   content=defaults.patch,
                   date=self.last_patch_ts)
     self.last_patch_ts += datetime.timedelta(0, 1)
     patch.save()
     return patch
开发者ID:anderco,项目名称:patchwork,代码行数:11,代码来源:test_xmlrpc.py

示例9: setUp

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
    def setUp(self):
        defaults.project.save()

        for (name, email, date) in self.patchmeta:
            patch_name = 'testpatch' + name
            person = Person(name = name, email = email)
            person.save()
            patch = Patch(project = defaults.project, msgid = patch_name,
                        submitter = person, content = '', date = date)
            patch.save()
开发者ID:lsandoval,项目名称:patchwork,代码行数:12,代码来源:test_list.py

示例10: testList

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
    def testList(self):
        defaults.project.save()
        defaults.patch_author_person.save()
        patch = Patch(project = defaults.project,
                submitter = defaults.patch_author_person,
                msgid = defaults.patch_name,
                content = defaults.patch)
        patch.save()

        patches = self.rpc.patch_list()
        self.assertEqual(len(patches), 1)
        self.assertEqual(patches[0]['id'], patch.id)
开发者ID:computersforpeace,项目名称:patchwork,代码行数:14,代码来源:test_xmlrpc.py

示例11: create_patches

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
def create_patches(count=1):
    """Create 'count' unique patches."""
    defaults.project.save()
    defaults.patch_author_person.save()

    patches = []

    for i in range(0, count):
        patch = Patch(project=defaults.project,
                      submitter=defaults.patch_author_person,
                      msgid=make_msgid(),
                      name='testpatch%d' % (i + 1),
                      diff=defaults.patch)
        patch.save()
        patches.append(patch)

    return patches
开发者ID:doanac,项目名称:patchwork,代码行数:19,代码来源:utils.py

示例12: setUp

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
    def setUp(self, patch_count=3):
        patch_names = ['testpatch%d' % (i) for i in range(1, patch_count+1)]
        self.user = create_user()
        self.client.login(username = self.user.username,
                password = self.user.username)
        defaults.project.save()
        self.bundle = Bundle(owner = self.user, project = defaults.project,
                name = 'testbundle')
        self.bundle.save()
        self.patches = []

        for patch_name in patch_names:
            patch = Patch(project = defaults.project,
                               msgid = patch_name, name = patch_name,
                               submitter = Person.objects.get(user = self.user),
                               content = '')
            patch.save()
            self.patches.append(patch)
开发者ID:lsandoval,项目名称:patchwork,代码行数:20,代码来源:test_bundles.py

示例13: setUp

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
 def setUp(self):
     defaults.project.save()
     self.user = create_maintainer(defaults.project)
     self.client.login(username = self.user.username,
             password = self.user.username)
     self.properties_form_id = 'patchform-properties'
     self.url = reverse(
         'patchwork.views.patch.list', args = [defaults.project.linkname])
     self.base_data = {
         'action': 'Update', 'project': str(defaults.project.id),
         'form': 'patchlistform', 'archived': '*', 'delegate': '*',
         'state': '*'}
     self.patches = []
     for name in ['patch one', 'patch two', 'patch three']:
         patch = Patch(project = defaults.project, msgid = name,
                         name = name, content = '',
                         submitter = Person.objects.get(user = self.user))
         patch.save()
         self.patches.append(patch)
开发者ID:tijuca,项目名称:patchwork,代码行数:21,代码来源:updates.py

示例14: testPatchSubmitterExpiry

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
    def testPatchSubmitterExpiry(self):
        defaults.project.save()
        defaults.patch_author_person.save()

        # someone submits a patch...
        patch = Patch(project=defaults.project,
                      msgid='[email protected]', name='test patch',
                      submitter=defaults.patch_author_person,
                      content=defaults.patch)
        patch.save()

        # ... then starts registration...
        date = ((datetime.datetime.now() - EmailConfirmation.validity) -
                datetime.timedelta(hours=1))
        userid = 'test-user'
        user = User.objects.create_user(
            userid,
            defaults.patch_author_person.email, userid)
        user.is_active = False
        user.date_joined = user.last_login = date
        user.save()

        self.assertEqual(user.email, patch.submitter.email)

        conf = EmailConfirmation(type='registration', user=user,
                                 email=user.email)
        conf.date = date
        conf.save()

        # ... which expires
        do_expiry()

        # we should see no matching user
        self.assertFalse(User.objects.filter(email=patch.submitter.email)
                         .exists())
        # but the patch and person should still be present
        self.assertTrue(Person.objects.filter(
            pk=defaults.patch_author_person.pk).exists())
        self.assertTrue(Patch.objects.filter(pk=patch.pk).exists())

        # and there should be no user associated with the person
        self.assertEqual(Person.objects.get(
            pk=defaults.patch_author_person.pk).user, None)
开发者ID:anderco,项目名称:patchwork,代码行数:45,代码来源:test_expiry.py

示例15: create_patch

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import save [as 别名]
def create_patch(**kwargs):
    """Create 'Patch' object."""
    num = Patch.objects.count()

    values = {
        'submitter': create_person(),
        'delegate': None,
        'project': create_project(),
        'msgid': make_msgid(),
        'name': 'testpatch%d' % num,
        'headers': '',
        'content': '',
        'diff': SAMPLE_DIFF,
    }
    values.update(kwargs)

    patch = Patch(**values)
    patch.save()

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


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