Exemple #1
0
    def test_unsubscribe_nonexistant(self):
        jobs_before = celery_pubsub.pubsub._pubsub_manager.get_jobs(
            'not.exists').tasks
        celery_pubsub.unsubscribe('not.exists', job_a)
        jobs_after = celery_pubsub.pubsub._pubsub_manager.get_jobs(
            'not.exists').tasks

        self.assertListEqual(jobs_before, jobs_after)
def test_unsubscribe_nonexistant(subscriber, job_a, celery_worker):
    import celery_pubsub

    jobs_before = celery_pubsub.pubsub._pubsub_manager.get_jobs(
        "not.exists").tasks
    celery_pubsub.unsubscribe("not.exists", job_a)
    jobs_after = celery_pubsub.pubsub._pubsub_manager.get_jobs(
        "not.exists").tasks

    assert jobs_before == jobs_after
Exemple #3
0
    def test_subscription(self):
        from celery_pubsub import publish, subscribe
        res = publish('dummy', 4, 8, a15=16, a23=42).get()
        self.assertListEqual(sorted(res), sorted(['e']))

        subscribe('dummy', job_c)

        res = publish('dummy', 4, 8, a15=16, a23=42).get()
        self.assertListEqual(sorted(res), sorted(['e', 'c']))

        celery_pubsub.unsubscribe('dummy', job_c)

        res = publish('dummy', 4, 8, a15=16, a23=42).get()
        self.assertListEqual(sorted(res), sorted(['e']))
Exemple #4
0
    def test_subscription_redundant(self):
        jobs_init = celery_pubsub.pubsub._pubsub_manager.get_jobs(
            'redundant.test').tasks
        celery_pubsub.subscribe('redundant.test', job_a)
        jobs_before = celery_pubsub.pubsub._pubsub_manager.get_jobs(
            'redundant.test').tasks
        celery_pubsub.subscribe('redundant.test', job_a)
        jobs_after = celery_pubsub.pubsub._pubsub_manager.get_jobs(
            'redundant.test').tasks
        celery_pubsub.unsubscribe('redundant.test', job_a)
        jobs_end = celery_pubsub.pubsub._pubsub_manager.get_jobs(
            'redundant.test').tasks

        self.assertListEqual(jobs_before, jobs_after)
        self.assertListEqual(jobs_init, jobs_end)
def test_subscription(subscriber, job_c, celery_worker):
    from celery_pubsub import publish, subscribe

    res = publish("dummy", 4, 8, a15=16, a23=42).get()
    assert sorted(res) == sorted(["e"])

    subscribe("dummy", job_c)

    res = publish("dummy", 4, 8, a15=16, a23=42).get()
    assert sorted(res) == sorted(["e", "c"])

    unsubscribe("dummy", job_c)

    res = publish("dummy", 4, 8, a15=16, a23=42).get()
    assert sorted(res) == sorted(["e"])
def test_subscription_redundant(subscriber, job_a, celery_worker):
    import celery_pubsub

    jobs_init = celery_pubsub.pubsub._pubsub_manager.get_jobs(
        "redundant.test").tasks
    celery_pubsub.subscribe("redundant.test", job_a)
    jobs_before = celery_pubsub.pubsub._pubsub_manager.get_jobs(
        "redundant.test").tasks
    celery_pubsub.subscribe("redundant.test", job_a)
    jobs_after = celery_pubsub.pubsub._pubsub_manager.get_jobs(
        "redundant.test").tasks
    celery_pubsub.unsubscribe("redundant.test", job_a)
    jobs_end = celery_pubsub.pubsub._pubsub_manager.get_jobs(
        "redundant.test").tasks

    assert jobs_before == jobs_after
    assert jobs_init == jobs_end