本文整理汇总了Python中patchwork.models.Patch类的典型用法代码示例。如果您正苦于以下问题:Python Patch类的具体用法?Python Patch怎么用?Python Patch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Patch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _insert_patch
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
示例2: MboxPatchResponseTest
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')
示例3: MboxDateHeaderTest
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)
示例4: MboxCommentPostcriptUnchangedTest
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)
示例5: MboxPatchSplitResponseTest
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')
示例6: MboxGeneratedHeaderTest
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)
示例7: MboxPassThroughHeaderTest
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)
示例8: _insert_patch
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
示例9: setUp
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()
示例10: testList
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)
示例11: create_patches
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
示例12: setUp
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()
示例13: setUp
def setUp(self):
self.project = defaults.project
self.project.send_notifications = True
self.project.save()
self.submitter = defaults.patch_author_person
self.submitter.save()
self.patch = Patch(project = self.project, msgid = 'testpatch',
name = 'testpatch', content = '',
submitter = self.submitter)
示例14: setUp
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)
示例15: setUp
def setUp(self):
project = defaults.project
defaults.project.save()
defaults.patch_author_person.save()
self.patch = Patch(project=project,
msgid='x', name=defaults.patch_name,
submitter=defaults.patch_author_person,
diff='')
self.patch.save()
self.user = create_user()