Exemplo n.º 1
0
    def test_mediator_body_exception(self):
        ready_queue = Queue()

        def mycallback(value):
            raise KeyError('foo')

        m = Mediator(ready_queue, mycallback)
        ready_queue.put(MockTask('Elaine M. Benes'))

        m.body()
    def test_mediator_body(self):
        ready_queue = Queue()
        got = {}

        def mycallback(value):
            got["value"] = value.value

        m = Mediator(ready_queue, mycallback)
        ready_queue.put(MockTask("George Costanza"))

        m.body()

        self.assertEqual(got["value"], "George Costanza")
Exemplo n.º 3
0
    def test_mediator_body(self):
        ready_queue = Queue()
        got = {}

        def mycallback(value):
            got["value"] = value.value

        m = Mediator(ready_queue, mycallback)
        ready_queue.put(MockTask("George Costanza"))

        m.body()

        self.assertEqual(got["value"], "George Costanza")
    def test_mediator_body_revoked(self):
        ready_queue = Queue()
        got = {}

        def mycallback(value):
            got["value"] = value.value

        m = Mediator(ready_queue, mycallback)
        t = MockTask("Jerry Seinfeld")
        t.task_id = uuid()
        revoked_tasks.add(t.task_id)
        ready_queue.put(t)

        m.body()

        self.assertNotIn("value", got)
        self.assertTrue(t.on_ack.call_count)
Exemplo n.º 5
0
    def test_mediator_body_revoked(self):
        ready_queue = Queue()
        got = {}

        def mycallback(value):
            got['value'] = value.value

        m = Mediator(ready_queue, mycallback)
        t = MockTask('Jerry Seinfeld')
        t.id = uuid()
        revoked_tasks.add(t.id)
        ready_queue.put(t)

        m.body()

        self.assertNotIn('value', got)
        self.assertTrue(t.on_ack.call_count)
Exemplo n.º 6
0
    def test_mediator_body(self):
        ready_queue = Queue()
        got = {}

        def mycallback(value):
            got['value'] = value.value

        m = Mediator(ready_queue, mycallback)
        ready_queue.put(MockTask('George Costanza'))

        m.body()

        self.assertEqual(got['value'], 'George Costanza')

        ready_queue.put(MockTask('Jerry Seinfeld'))
        m._does_debug = False
        m.body()
        self.assertEqual(got['value'], 'Jerry Seinfeld')