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


Python tests.watch函数代码示例

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


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


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