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


Python Patch.delete方法代码示例

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


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

示例1: UTF8HeaderPatchViewTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import delete [as 别名]
class UTF8HeaderPatchViewTest(UTF8PatchViewTest):
    patch_filename = '0002-utf-8.patch'
    patch_encoding = 'utf-8'
    patch_author_name = u'P\xe4tch Author'

    def setUp(self):
        defaults.project.save()
        self.patch_author = Person(name = self.patch_author_name,
            email = defaults.patch_author_person.email)
        self.patch_author.save()
        self.patch_content = read_patch(self.patch_filename,
                encoding = self.patch_encoding)
        self.patch = Patch(project = defaults.project,
                           msgid = 'x', name = defaults.patch_name,
                           submitter = self.patch_author,
                           content = self.patch_content)
        self.patch.save()
        self.client = Client()

    def tearDown(self):
        self.patch.delete()
        self.patch_author.delete()
        defaults.project.delete()
开发者ID:asl,项目名称:llvm-patchwork,代码行数:25,代码来源:encodings.py

示例2: UTF8PatchViewTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import delete [as 别名]
class UTF8PatchViewTest(TestCase):
    fixtures = ['default_states', 'default_events']
    patch_filename = '0002-utf-8.patch'
    patch_encoding = 'utf-8'

    def setUp(self):
        defaults.project.save()
        defaults.patch_author_person.save()
        self.patch_content = read_patch(self.patch_filename,
                encoding = self.patch_encoding)
        self.patch = Patch(project = defaults.project,
                           msgid = 'x', name = defaults.patch_name,
                           submitter = defaults.patch_author_person,
                           content = self.patch_content)
        self.patch.save()
        self.client = Client()

    def testPatchView(self):
        response = self.client.get('/patch/%d/' % self.patch.id)
        self.assertContains(response, self.patch.name)

    def testMboxView(self):
        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
        self.assertEquals(response.status_code, 200)
        self.assertTrue(self.patch.content in \
                response.content.decode(self.patch_encoding))

    def testRawView(self):
        response = self.client.get('/patch/%d/raw/' % self.patch.id)
        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.content.decode(self.patch_encoding),
                self.patch.content)

    def tearDown(self):
        self.patch.delete()
        defaults.patch_author_person.delete()
        defaults.project.delete()
开发者ID:lsandoval,项目名称:patchwork,代码行数:39,代码来源:test_encodings.py

示例3: PatchTagsTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import delete [as 别名]
class PatchTagsTest(TransactionTestCase):
    ACK = 1
    REVIEW = 2
    TEST = 3
    fixtures = ['default_tags', 'default_states']

    def assertTagsEqual(self, patch, acks, reviews, tests):
        patch = Patch.objects.get(pk=patch.pk)

        def count(name):
            try:
                return patch.patchtag_set.get(tag__name=name).count
            except PatchTag.DoesNotExist:
                return 0

        counts = (
            count(name='Acked-by'),
            count(name='Reviewed-by'),
            count(name='Tested-by'),
        )

        self.assertEqual(counts, (acks, reviews, tests))

    def create_tag(self, tagtype = None):
        tags = {
            self.ACK: 'Acked',
            self.REVIEW: 'Reviewed',
            self.TEST: 'Tested'
        }
        if tagtype not in tags:
            return ''
        return '%s-by: %s\n' % (tags[tagtype], self.tagger)

    def create_tag_comment(self, patch, tagtype = None):
        comment = Comment(patch=patch, msgid=str(datetime.datetime.now()),
                submitter=defaults.patch_author_person,
                content=self.create_tag(tagtype))
        comment.save()
        return comment

    def setUp(self):
        settings.DEBUG = True
        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]>'

    def tearDown(self):
        self.patch.delete()

    def testNoComments(self):
        self.assertTagsEqual(self.patch, 0, 0, 0)

    def testNoTagComment(self):
        self.create_tag_comment(self.patch, None)
        self.assertTagsEqual(self.patch, 0, 0, 0)

    def testSingleComment(self):
        self.create_tag_comment(self.patch, self.ACK)
        self.assertTagsEqual(self.patch, 1, 0, 0)

    def testMultipleComments(self):
        self.create_tag_comment(self.patch, self.ACK)
        self.create_tag_comment(self.patch, self.ACK)
        self.assertTagsEqual(self.patch, 2, 0, 0)

    def testMultipleCommentTypes(self):
        self.create_tag_comment(self.patch, self.ACK)
        self.create_tag_comment(self.patch, self.REVIEW)
        self.create_tag_comment(self.patch, self.TEST)
        self.assertTagsEqual(self.patch, 1, 1, 1)

    def testCommentAdd(self):
        self.create_tag_comment(self.patch, self.ACK)
        self.assertTagsEqual(self.patch, 1, 0, 0)
        self.create_tag_comment(self.patch, self.ACK)
        self.assertTagsEqual(self.patch, 2, 0, 0)

    def testCommentUpdate(self):
        comment = self.create_tag_comment(self.patch, self.ACK)
        self.assertTagsEqual(self.patch, 1, 0, 0)

        comment.content += self.create_tag(self.ACK)
        comment.save()
        self.assertTagsEqual(self.patch, 2, 0, 0)

    def testCommentDelete(self):
        comment = self.create_tag_comment(self.patch, self.ACK)
        self.assertTagsEqual(self.patch, 1, 0, 0)
        comment.delete()
        self.assertTagsEqual(self.patch, 0, 0, 0)

    def testSingleCommentMultipleTags(self):
        comment = self.create_tag_comment(self.patch, self.ACK)
#.........这里部分代码省略.........
开发者ID:computersforpeace,项目名称:patchwork,代码行数:103,代码来源:test_tags.py

示例4: PatchNotificationModelTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import delete [as 别名]
class PatchNotificationModelTest(TestCase):
    """Tests for the creation & update of the PatchChangeNotification model"""

    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)

    def tearDown(self):
        self.patch.delete()
        self.submitter.delete()
        self.project.delete()

    def testPatchCreation(self):
        """Ensure we don't get a notification on create"""
        self.patch.save()
        self.assertEqual(PatchChangeNotification.objects.count(), 0)

    def testPatchUninterestingChange(self):
        """Ensure we don't get a notification for "uninteresting" changes"""
        self.patch.save()
        self.patch.archived = True
        self.patch.save()
        self.assertEqual(PatchChangeNotification.objects.count(), 0)

    def testPatchChange(self):
        """Ensure we get a notification for interesting patch changes"""
        self.patch.save()
        oldstate = self.patch.state
        state = State.objects.exclude(pk = oldstate.pk)[0]

        self.patch.state = state
        self.patch.save()
        self.assertEqual(PatchChangeNotification.objects.count(), 1)
        notification = PatchChangeNotification.objects.all()[0]
        self.assertEqual(notification.patch, self.patch)
        self.assertEqual(notification.orig_state, oldstate)

    def testNotificationCancelled(self):
        """Ensure we cancel notifications that are no longer valid"""
        self.patch.save()
        oldstate = self.patch.state
        state = State.objects.exclude(pk = oldstate.pk)[0]

        self.patch.state = state
        self.patch.save()
        self.assertEqual(PatchChangeNotification.objects.count(), 1)

        self.patch.state = oldstate
        self.patch.save()
        self.assertEqual(PatchChangeNotification.objects.count(), 0)

    def testNotificationUpdated(self):
        """Ensure we update notifications when the patch has a second change,
           but keep the original patch details"""
        self.patch.save()
        oldstate = self.patch.state
        newstates = State.objects.exclude(pk = oldstate.pk)[:2]

        self.patch.state = newstates[0]
        self.patch.save()
        self.assertEqual(PatchChangeNotification.objects.count(), 1)
        notification = PatchChangeNotification.objects.all()[0]
        self.assertEqual(notification.orig_state, oldstate)
        orig_timestamp = notification.last_modified
                         
        self.patch.state = newstates[1]
        self.patch.save()
        self.assertEqual(PatchChangeNotification.objects.count(), 1)
        notification = PatchChangeNotification.objects.all()[0]
        self.assertEqual(notification.orig_state, oldstate)
        self.assertTrue(notification.last_modified > orig_timestamp)

    def testProjectNotificationsDisabled(self):
        """Ensure we don't see notifications created when a project is
           configured not to send them"""
        self.project.send_notifications = False
        self.project.save()

        self.patch.save()
        oldstate = self.patch.state
        state = State.objects.exclude(pk = oldstate.pk)[0]

        self.patch.state = state
        self.patch.save()
        self.assertEqual(PatchChangeNotification.objects.count(), 0)
开发者ID:tijuca,项目名称:patchwork,代码行数:93,代码来源:notifications.py

示例5: PatchNotificationEmailTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import delete [as 别名]
class PatchNotificationEmailTest(TestCase):

    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)
        self.patch.save()

    def tearDown(self):
        self.patch.delete()
        self.submitter.delete()
        self.project.delete()

    def _expireNotifications(self, **kwargs):
        timestamp = datetime.datetime.now() - \
                    datetime.timedelta(minutes =
                            settings.NOTIFICATION_DELAY_MINUTES + 1)

        qs = PatchChangeNotification.objects.all()
        if kwargs:
            qs = qs.filter(**kwargs)

        qs.update(last_modified = timestamp)

    def testNoNotifications(self):
        self.assertEquals(send_notifications(), [])

    def testNoReadyNotifications(self):
        """ We shouldn't see immediate notifications"""
        PatchChangeNotification(patch = self.patch,
                               orig_state = self.patch.state).save()

        errors = send_notifications()
        self.assertEquals(errors, [])
        self.assertEquals(len(mail.outbox), 0)

    def testNotifications(self):
        PatchChangeNotification(patch = self.patch,
                               orig_state = self.patch.state).save()
        self._expireNotifications()

        errors = send_notifications()
        self.assertEquals(errors, [])
        self.assertEquals(len(mail.outbox), 1)
        msg = mail.outbox[0]
        self.assertEquals(msg.to, [self.submitter.email])
        self.assertTrue(self.patch.get_absolute_url() in msg.body)

    def testNotificationEscaping(self):
        self.patch.name = 'Patch name with " character'
        self.patch.save()
        PatchChangeNotification(patch = self.patch,
                               orig_state = self.patch.state).save()
        self._expireNotifications()

        errors = send_notifications()
        self.assertEquals(errors, [])
        self.assertEquals(len(mail.outbox), 1)
        msg = mail.outbox[0]
        self.assertEquals(msg.to, [self.submitter.email])
        self.assertFalse('&quot;' in msg.body)

    def testNotificationOptout(self):
        """ensure opt-out addresses don't get notifications"""
        PatchChangeNotification(patch = self.patch,
                               orig_state = self.patch.state).save()
        self._expireNotifications()

        EmailOptout(email = self.submitter.email).save()

        errors = send_notifications()
        self.assertEquals(errors, [])
        self.assertEquals(len(mail.outbox), 0)

    def testNotificationMerge(self):
        patches = [self.patch,
                   Patch(project = self.project, msgid = 'testpatch-2',
                         name = 'testpatch 2', content = '',
                         submitter = self.submitter)]

        for patch in patches:
            patch.save()
            PatchChangeNotification(patch = patch,
                                   orig_state = patch.state).save()

        self.assertEquals(PatchChangeNotification.objects.count(), len(patches))
        self._expireNotifications()
        errors = send_notifications()
        self.assertEquals(errors, [])
        self.assertEquals(len(mail.outbox), 1)
        msg = mail.outbox[0]
        self.assertTrue(patches[0].get_absolute_url() in msg.body)
        self.assertTrue(patches[1].get_absolute_url() in msg.body)

    def testUnexpiredNotificationMerge(self):
#.........这里部分代码省略.........
开发者ID:tijuca,项目名称:patchwork,代码行数:103,代码来源:notifications.py

示例6: PatchChecksTest

# 需要导入模块: from patchwork.models import Patch [as 别名]
# 或者: from patchwork.models.Patch import delete [as 别名]
class PatchChecksTest(TransactionTestCase):
    fixtures = ['default_tags', 'default_states']

    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()

    def create_check(self, **kwargs):
        check_values = {
            'patch': self.patch,
            'user': self.user,
            'date': dt.now(),
            'state': Check.STATE_SUCCESS,
            'target_url': 'http://example.com/',
            'description': '',
            'context': 'intel/jenkins-ci',
        }

        for key in check_values:
            if key in kwargs:
                check_values[key] = kwargs[key]

        check = Check(**check_values)
        check.save()
        return check

    def assertCheckEqual(self, patch, check_state):
        self.assertEqual(self.patch.combined_check_state, check_state)

    def assertChecksEqual(self, patch, checks=None):
        if not checks:
            checks = []

        self.assertEqual(len(self.patch.checks), len(checks))
        self.assertEqual(
            sorted(self.patch.checks, key=lambda check: check.id),
            sorted(checks, key=lambda check: check.id))

    def assertCheckCountEqual(self, patch, total, state_counts=None):
        if not state_counts:
            state_counts = {}

        counts = self.patch.check_count

        self.assertEqual(self.patch.check_set.count(), total)

        for state in state_counts:
            self.assertEqual(counts[state], state_counts[state])

        # also check the ones we didn't explicitly state
        for state, _ in Check.STATE_CHOICES:
            if state not in state_counts:
                self.assertEqual(counts[state], 0)

    def tearDown(self):
        self.patch.delete()

    def test_checks__no_checks(self):
        self.assertChecksEqual(self.patch, [])

    def test_checks__single_check(self):
        check = self.create_check()
        self.assertChecksEqual(self.patch, [check])

    def test_checks__multiple_checks(self):
        check_a = self.create_check()
        check_b = self.create_check(context='new-context/test1')
        self.assertChecksEqual(self.patch, [check_a, check_b])

    def test_checks__duplicate_checks(self):
        self.create_check(date=(dt.now() - timedelta(days=1)))
        check = self.create_check()
        # this isn't a realistic scenario (dates shouldn't be set by user so
        #   they will always increment), but it's useful to verify the removal
        #   of older duplicates by the function
        self.create_check(date=(dt.now() - timedelta(days=2)))
        self.assertChecksEqual(self.patch, [check])

    def test_check_count__no_checks(self):
        self.assertCheckCountEqual(self.patch, 0)

    def test_check_count__single_check(self):
        self.create_check()
        self.assertCheckCountEqual(self.patch, 1, {Check.STATE_SUCCESS: 1})

    def test_check_count__multiple_checks(self):
        self.create_check(date=(dt.now() - timedelta(days=1)))
        self.create_check(context='new/test1')
        self.assertCheckCountEqual(self.patch, 2, {Check.STATE_SUCCESS: 2})

    def test_check_count__duplicate_check_same_state(self):
        self.create_check(date=(dt.now() - timedelta(days=1)))
        self.assertCheckCountEqual(self.patch, 1, {Check.STATE_SUCCESS: 1})
#.........这里部分代码省略.........
开发者ID:doanac,项目名称:patchwork,代码行数:103,代码来源:test_checks.py


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