• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tests.watch函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_filtered

    def test_filtered(self):
        """Make sure watches cull properly by additional filters."""
        # A watch with just the filter we're searching for:
        registered_user = user(email='[email protected]', save=True)
        exact_watch = watch(event_type=TYPE, user=registered_user, save=True)
        watch_filter(watch=exact_watch, name='color', value=1).save()

        # A watch with extra filters:
        extra_watch = watch(event_type=TYPE, email='[email protected]', save=True)
        watch_filter(watch=extra_watch, name='color', value=1).save()
        watch_filter(watch=extra_watch, name='flavor', value=2).save()

        # A watch with no row for the filter we're searching on:
        watch(event_type=TYPE, email='[email protected]').save()

        # A watch with a mismatching filter--shouldn't be found
        mismatch_watch = watch(event_type=TYPE, email='[email protected]',
                               save=True)
        watch_filter(watch=mismatch_watch, name='color', value=3).save()

        self._emails_eq(['[email protected]', '[email protected]', '[email protected]'],
                        FilteredEvent(), color=1)

        # Search on multiple filters to test joining the filters table twice.
        # We provide values that match for both filters, as [email protected]
        # suffices to test exclusion.
        self._emails_eq(['[email protected]', '[email protected]', '[email protected]'],
                        FilteredEvent(), color=1, flavor=2)
开发者ID:AprilMorone,项目名称:kuma,代码行数:28,代码来源:test_events.py


示例2: test_duplicate_tolerance

    def test_duplicate_tolerance(self):
        """Assure notify() returns an existing watch if there is a matching
        one.

        Also make sure it returns only 1 watch even if there are duplicate
        matches.

        """
        w1 = watch(event_type=TYPE, email='[email protected]', save=True)
        w2 = watch(event_type=TYPE, email='[email protected]', save=True)
        assert SimpleEvent.notify('[email protected]').pk in [w1.pk, w2.pk]
开发者ID:AprilMorone,项目名称:kuma,代码行数:11,代码来源:test_events.py


示例3: test_mock_model

    def test_mock_model(self):
        """Deleting an instance of MockModel should delete watches.

        Create instance of MockModel from notifications.tests.models, then
        delete it and watch the cascade go.

        """
        mock_m = MockModel.objects.create()
        watch(event_type=TYPE, email='[email protected]', content_object=mock_m,
              save=True)
        MockModel.objects.all().delete()
        assert not Watch.objects.count(), 'Cascade delete failed.'
开发者ID:AprilMorone,项目名称:kuma,代码行数:12,代码来源:test_events.py


示例4: test_new_user_claim_watches

    def test_new_user_claim_watches(self, get_current):
        """Claim user watches upon activation."""
        watch(email='[email protected]', save=True)

        get_current.return_value.domain = 'su.mo.com'
        user = RegistrationProfile.objects.create_inactive_user(
            'sumouser1234', 'testpass', '[email protected]')
        key = RegistrationProfile.objects.all()[0].activation_key
        self.client.get(reverse('users.activate', args=[key]), follow=True)

        # Watches are claimed.
        assert user.watch_set.exists()
开发者ID:fwenzel,项目名称:kitsune,代码行数:12,代码来源:test_views.py


示例5: test_new_user_claim_watches

    def test_new_user_claim_watches(self, get_current):
        """Claim user watches upon activation."""
        old, settings.CELERY_ALWAYS_EAGER = settings.CELERY_ALWAYS_EAGER, True

        get_current.return_value.domain = 'su.mo.com'

        watch(email='[email protected]', save=True)

        now = time()
        username = 'sumo%s' % now
        user = RegistrationProfile.objects.create_inactive_user(
            username, 'testpass', '[email protected]')
        key = RegistrationProfile.objects.all()[0].activation_key
        self.client.get(reverse('users.activate', args=[key]), follow=True)

        # Watches are claimed.
        assert user.watch_set.exists()

        settings.CELERY_ALWAYS_EAGER = old
开发者ID:HarshaJagadish,项目名称:kuma,代码行数:19,代码来源:test_views.py


示例6: test_simple

 def test_simple(self):
     """Test whether a watch scoped only by event type fires for both
     anonymous and registered users."""
     registered_user = user(email='[email protected]', save=True)
     watch(event_type=TYPE, user=registered_user).save()
     watch(event_type=TYPE, email='[email protected]').save()
     watch(event_type='something else', email='[email protected]').save()
     self._emails_eq(['[email protected]', '[email protected]'], SimpleEvent())
开发者ID:AprilMorone,项目名称:kuma,代码行数:8,代码来源:test_events.py


示例7: test_duplicates

    def test_duplicates(self):
        """Don't return duplicate email addresses."""
        watch(event_type=TYPE, user=user(email='[email protected]', save=True),
              save=True)
        watch(event_type=TYPE, email='[email protected]').save()
        watch(event_type=TYPE, email='[email protected]').save()
        eq_(3, Watch.objects.all().count())  # We created what we meant to.

        self._emails_eq(['[email protected]'], SimpleEvent())
开发者ID:AprilMorone,项目名称:kuma,代码行数:9,代码来源:test_events.py


示例8: test_registered_users_favored

    def test_registered_users_favored(self):
        """When removing duplicates, make sure registered users are kept in
        favor of anonymous ones having the same email address."""
        def make_anonymous_watches():
            for x in xrange(3):
                watch(event_type=TYPE, email='[email protected]').save()

        # Throw some anonymous watches in there in the hope that they would
        # come out on top if we didn't purposely favor registered users.
        # Suggestions on how to make this test more reliable are welcome.
        make_anonymous_watches()

        # File the registered watch:
        watch(event_type=TYPE,
              user=user(first_name='Jed', email='[email protected]',
                        save=True)).save()

        # A few more anonymous watches in case the BTrees flop in the other
        # direction:
        make_anonymous_watches()

        users_and_watches = list(SimpleEvent()._users_watching_by_filter())
        u, w = users_and_watches[0]
        eq_('Jed', u.first_name)
开发者ID:AprilMorone,项目名称:kuma,代码行数:24,代码来源:test_events.py


示例9: test_merging

    def test_merging(self):
        """Test that duplicate emails across multiple events get merged."""
        # Remember to keep the emails in order when writing these test cases.
        # [Ed: But doesn't the SQL query have an ORDER BY?]
        watch(event_type=TYPE, email='[email protected]').save()
        watch(event_type=TYPE, email='[email protected]').save()
        registered_user = user(email='[email protected]', save=True)
        watch(event_type=ANOTHER_TYPE, user=registered_user).save()

        self._emails_eq(['[email protected]', '[email protected]'],
                        EventUnion(SimpleEvent(), AnotherEvent()))
开发者ID:AprilMorone,项目名称:kuma,代码行数:11,代码来源:test_events.py


示例10: test_duplicates_case_insensitive

    def test_duplicates_case_insensitive(self):
        """De-duping should compare case-insensitively."""
        watch(event_type=TYPE, user=user(email='[email protected]', save=True),
              save=True)
        watch(event_type=TYPE, email='[email protected]').save()
        watch(event_type=TYPE, email='[email protected]').save()
        eq_(3, Watch.objects.all().count())  # We created what we meant to.

        addresses = [u.email
                     for u, w in SimpleEvent()._users_watching_by_filter()]
        eq_(1, len(addresses))
        eq_('[email protected]', addresses[0].lower())
开发者ID:AprilMorone,项目名称:kuma,代码行数:12,代码来源:test_events.py


示例11: test_content_type

 def test_content_type(self):
     """Make sure watches filter properly by content type."""
     watch_type = ContentType.objects.get_for_model(Watch)
     content_type_type = ContentType.objects.get_for_model(ContentType)
     registered_user = user(email='[email protected]', save=True)
     watch(event_type=TYPE, content_type=content_type_type,
           user=registered_user).save()
     watch(event_type=TYPE, content_type=content_type_type,
           email='[email protected]').save()
     watch(event_type=TYPE, content_type=watch_type,
           email='[email protected]').save()
     self._emails_eq(['[email protected]', '[email protected]'],
                     ContentTypeEvent())
开发者ID:AprilMorone,项目名称:kuma,代码行数:13,代码来源:test_events.py


示例12: test_anonymous_only

    def test_anonymous_only(self):
        """Make sure having mixed watches claims right ones."""
        # Watch some before registering.
        watch(email='some[email protected]', save=True)
        watch(email='[email protected]', save=True)
        watch(email='[email protected]', save=True)

        # Register.
        u = user(email='[email protected]', save=True)

        claim_watches(u)

        # Original anonymous watch is claimed.
        assert not Watch.objects.filter(email='[email protected]').exists()
        eq_(2, Watch.objects.filter(email=None).count())
        eq_(2, Watch.objects.filter(user=u).count())

        # No other watches are affected.
        assert Watch.objects.filter(email='[email protected]').exists()
开发者ID:gerv,项目名称:kuma,代码行数:19,代码来源:test_tasks.py


示例13: _users_watching

 def _users_watching(self):
     return [(user(email='[email protected]'), watch()),
             (user(email='[email protected]'), watch())]
开发者ID:AprilMorone,项目名称:kuma,代码行数:3,代码来源:test_events.py


示例14: test_inactive

 def test_inactive(self):
     """Make sure inactive watches don't fire."""
     watch(event_type=TYPE, email='[email protected]', is_active=False).save()
     watch(event_type=TYPE, email='[email protected]').save()
     self._emails_eq(['[email protected]'], SimpleEvent())
开发者ID:AprilMorone,项目名称:kuma,代码行数:5,代码来源:test_events.py


示例15: test_fire

 def test_fire(self, _mails):
     """Assert firing the union gets the mails from the first event."""
     watch(event_type=TYPE, email='[email protected]').save()
     EventUnion(SimpleEvent(), AnotherEvent()).fire()
     assert _mails.called
开发者ID:AprilMorone,项目名称:kuma,代码行数:5,代码来源:test_events.py


示例16: test_unique_by_email

    def test_unique_by_email(self):
        """Test the routine that sorts through users and watches having the
        same email addresses."""
        # Test the best in a cluster coming first, in the middle, and last.
        # We mark the correct choices with secret='a'.
        users_and_watches = [
            (user(email='hi'), watch(secret='a')),
            (user(email='hi'), watch()),
            (user(), watch(email='hi')),

            (user(), watch(email='mid')),
            (user(email='mid'), watch(secret='a')),
            (user(), watch(email='mid')),

            (user(), watch(email='lo')),
            (user(), watch(email='lo')),
            (user(email='lo'), watch(secret='a')),

            (user(), watch(email='none', secret='a')),
            (user(), watch(email='none')),

            (user(), watch(email='hi', secret='a')),
            (user(), watch(email='hi')),
            (user(), watch(email='hi'))]

        favorites = list(_unique_by_email(users_and_watches))
        num_clusters = 5
        eq_(num_clusters, len(favorites))
        eq_(['a'] * num_clusters, [w.secret for u, w in favorites])
开发者ID:AprilMorone,项目名称:kuma,代码行数:29,代码来源:test_events.py


示例17: make_anonymous_watches

 def make_anonymous_watches():
     for x in xrange(3):
         watch(event_type=TYPE, email='[email protected]').save()
开发者ID:AprilMorone,项目名称:kuma,代码行数:3,代码来源:test_events.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.User类代码示例发布时间:2022-05-27
下一篇:
Python notify.send函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap