예제 #1
0
파일: tests.py 프로젝트: ninowalker/voom
    def test_nesting_using_in_same_scope(self):
        bus = VoomBus(raise_errors=True)
        data1 = {1: 2, 2: 2, 3: 2}
        data2 = {"a": True}

        with bus.using(data1):
            self.assertEquals(data1, bus.frame)
            with bus.using(data2):
                self.assertEquals(data2, bus.frame)
                self.assertDictContainsSubset(data1, bus.frame)
예제 #2
0
파일: tests.py 프로젝트: ninowalker/voom
    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)
예제 #3
0
파일: tests.py 프로젝트: ninowalker/voom
 def test_new_frame_when_in_using(self):
     bus = VoomBus()
     data = {1: 2}
     self.assertEqual({}, bus.frame)
     with bus.using(data):
         self.assertEqual(data, bus.frame)
     self.assertEqual({}, bus.frame)
예제 #4
0
파일: tests.py 프로젝트: Livefyre/voom
    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
예제 #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
예제 #6
0
파일: tests.py 프로젝트: Livefyre/voom
    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()
예제 #7
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()
예제 #8
0
파일: tests.py 프로젝트: Livefyre/voom
 def func1():
     with bus.using(data1):
         func2()
예제 #9
0
파일: tests.py 프로젝트: Livefyre/voom
 def func2():
     with bus.using(data2):
         func3()
예제 #10
0
파일: tests.py 프로젝트: Livefyre/voom
 def test1(self):
     bus = VoomBus()
     data = {1: 2}
     with bus.using(data):
         assert bus._trx_proxy.session_future == data, bus._session_data.data
     assert bus._trx_proxy.session_future is None, bus._session_data.data
예제 #11
0
 def func1():
     with bus.using(data1):
         func2()
예제 #12
0
 def func2():
     with bus.using(data2):
         func3()
예제 #13
0
 def test1(self):
     bus = VoomBus()
     data = {1: 2}
     with bus.using(data):
         assert bus._trx_proxy.session_future == data, bus._session_data.data
     assert bus._trx_proxy.session_future is None, bus._session_data.data