Ejemplo n.º 1
0
    def test_task_is_in_queue(self):
        REDIS.flushall()

        task = Task()
        decorated = task(unblocker)  # Pushes onto registry dict

        tm = ThreadManager(1, [('1')])

        task_data_string = REDIS.lpop(resolve_group_namespace(1))
        self.assertIsNone(
            task_data_string)  # We haven't loaded the task into REDIS yet.

        decorated.soon()  # Now it's in there.
        d = tm.control(
        )  # Run the next task in line, which we hope to be the above.

        def assert_that_unblocker_ran(n):
            unblocked_code = q.get(
            )  # The q will have pushed the random string.
            self.assertEqual(unblocked_code, random_string)

        d.addCallback(assert_that_unblocker_ran)

        return d