Exemple #1
0
    def test_still_sends_on_error(self):

        bus = VoomBus()
        msgs = []
        bus.subscribe(bus.ALL, lambda m: msgs.append((m, bus.session, bus.trx)))
        d = dict(a=1)
        with nose.tools.assert_raises(ValueError):  # @UndefinedVariable
            with bus.transaction() as (nested, state):
                assert not nested
                with bus.using(d):
                    self.assertEqual(d, bus.session)
                    bus.publish(1)
                    # this should not send the message, until
                    # until we exit the transaction block
                    self.assertEqual([], msgs)
                self.assertEqual([], msgs)
                int("a")
                self.fail("how'd I get here")

        # ensure we didn't lose the message
        self.assertEqual(1, len(msgs))
        m, frame, trx = msgs[0]
        self.assertEqual(1, m)
        self.assertEqual(True, trx.is_queue_empty())
        self.assertEqual({}, bus.frame)
        self.assertEqual(d, frame)
Exemple #2
0
    def test_send_on_exit(self):
        bus = VoomBus()
        self.msgs = []
        bus.subscribe(bus.ALL, self.msgs.append)

        with bus.transaction() as (nested, state):
            with bus.using(dict(a=1)):
                bus.publish(1)
            assert not self.msgs
            assert isinstance(state, TrxState)
            assert not state.is_queue_empty()

        assert self.msgs == [1]
        assert state.is_queue_empty()
Exemple #3
0
    def test_send_on_exit(self):
        bus = VoomBus()
        self.msgs = []
        bus.subscribe(bus.ALL, self.msgs.append)

        with bus.transaction() as (nested, state):
            with bus.using(dict(a=1)):
                bus.publish(1)
            assert not self.msgs
            assert isinstance(state, TrxState)
            assert not state.is_queue_empty()

        assert self.msgs == [1]
        assert state.is_queue_empty()
Exemple #4
0
    def test_send_on_error(self):
        bus = VoomBus()
        self.msgs = []
        bus.subscribe(bus.ALL, self.msgs.append)

        with nose.tools.assert_raises(ValueError): #@UndefinedVariable
            with bus.transaction() as (nested, state):
                assert not nested
                with bus.using(dict(a=1)):
                    assert bus.session == dict(a=1), bus.session
                    bus.publish(1)
                assert not self.msgs
                int("a")
                with bus.using(dict(a=1)):
                    bus.publish(1)

        assert self.msgs == [1]
        assert state.is_queue_empty()
        assert state.session == dict(a=1), state.session
Exemple #5
0
    def test_send_on_error(self):
        bus = VoomBus()
        self.msgs = []
        bus.subscribe(bus.ALL, self.msgs.append)

        with nose.tools.assert_raises(ValueError):  #@UndefinedVariable
            with bus.transaction() as (nested, state):
                assert not nested
                with bus.using(dict(a=1)):
                    assert bus.session == dict(a=1), bus.session
                    bus.publish(1)
                assert not self.msgs
                int("a")
                with bus.using(dict(a=1)):
                    bus.publish(1)

        assert self.msgs == [1]
        assert state.is_queue_empty()
        assert state.session == dict(a=1), state.session
Exemple #6
0
 def func3():
     bus.publish("1")
Exemple #7
0
 def func3():
     bus.publish("1")