def test_closed_cb_without_final_frame(self): c = Channel( 'connection', None, { 20: ChannelClass, 40: ExchangeClass, 50: QueueClass, 60: BasicClass, 90: TransactionClass, }) c._pending_events = 'foo' c._frame_buffer = 'foo' for val in c._class_map.values(): expect(val._cleanup) expect(c._notify_close_listeners) c._closed_cb() assert_equals(deque([]), c._pending_events) assert_equals(deque([]), c._frame_buffer) assert_equals(None, c._connection) assert_false(hasattr(c, 'channel')) assert_false(hasattr(c, 'exchange')) assert_false(hasattr(c, 'queue')) assert_false(hasattr(c, 'basic')) assert_false(hasattr(c, 'tx')) assert_equals(None, c._class_map) assert_equals(set(), c._close_listeners)
def test_clear_synchronous_cb_when_pending_cb_doesnt_match_but_isnt_in_list(self): c = Channel(None, None, {}) stub(c._flush_pending_events) c._pending_events = deque(['foo', 'bar']) assert_raises(ChannelError, c.clear_synchronous_cb, 'bar') assert_equals(deque(['foo', 'bar']), c._pending_events)
def test_clear_synchronous_cb_when_pending_cb_doesnt_match_but_isnt_in_list(self): c = Channel(None,None,{}) stub( c._flush_pending_events ) c._pending_events = deque(['foo', 'bar']) assertRaises( ChannelError, c.clear_synchronous_cb, 'bar' ) assertEquals( deque(['foo','bar']), c._pending_events )
def test_closed_cb_without_final_frame(self): c = Channel('connection', None, { 20: ChannelClass, 40: ExchangeClass, 50: QueueClass, 60: BasicClass, 90: TransactionClass, }) c._pending_events = 'foo' c._frame_buffer = 'foo' for val in c._class_map.values(): expect(val._cleanup) expect(c._notify_close_listeners) c._closed_cb() assert_equals(deque([]), c._pending_events) assert_equals(deque([]), c._frame_buffer) assert_equals(None, c._connection) assert_false(hasattr(c, 'channel')) assert_false(hasattr(c, 'exchange')) assert_false(hasattr(c, 'queue')) assert_false(hasattr(c, 'basic')) assert_false(hasattr(c, 'tx')) assert_equals(None, c._class_map) assert_equals(set(), c._close_listeners)
def test_clear_synchronous_cb_when_pending_cb_doesnt_match_but_isnt_in_list(self): c = Channel(None,None,{}) c._pending_events = deque(['foo']) expect( c._flush_pending_events ) assert_equals( 'bar', c.clear_synchronous_cb('bar') ) assertEquals( deque(['foo']), c._pending_events )
def test_clear_synchronous_cb_when_pending_cb_doesnt_match_but_isnt_in_list(self): c = Channel(None,None) c._pending_events = ['foo'] expect( c._flush_pending_events ) c.clear_synchronous_cb( 'bar' ) assertEquals( ['foo'], c._pending_events )
def test_clear_synchronous_cb_when_pending_cb_matches(self): c = Channel(None,None) c._pending_events = ['foo'] expect( c._flush_pending_events ) c.clear_synchronous_cb( 'foo' ) assertEquals( [], c._pending_events )
def test_clear_synchronous_cb_when_pending_cb_matches(self): c = Channel(None, None) c._pending_events = ['foo'] expect(c._flush_pending_events) c.clear_synchronous_cb('foo') assertEquals([], c._pending_events)
def test_clear_synchronous_cb_when_pending_cb_doesnt_match_but_isnt_in_list(self): c = Channel(None, None, {}) c._pending_events = deque(['foo']) expect(c._flush_pending_events) assert_equals('bar', c.clear_synchronous_cb('bar')) assert_equals(deque(['foo']), c._pending_events)
def test_clear_synchronous_cb_when_pending_cb_matches(self): c = Channel(None, None, {}) c._pending_events = deque(['foo']) expect(c._flush_pending_events) assert_equals('foo', c.clear_synchronous_cb('foo')) assert_equals(deque([]), c._pending_events)
def test_clear_synchronous_cb_when_pending_cb_matches(self): c = Channel(None, None, {}) c._pending_events = deque(['foo']) expect(c._flush_pending_events) assert_equals('foo', c.clear_synchronous_cb('foo')) assertEquals(deque([]), c._pending_events)
def test_clear_synchronous_cb_when_pending_cb_doesnt_match_but_isnt_in_list( self): c = Channel(None, None) c._pending_events = ['foo'] expect(c._flush_pending_events) c.clear_synchronous_cb('bar') assertEquals(['foo'], c._pending_events)
def test_flush_pending_events_flushes_all_leading_frames(self): conn = mock() c = Channel(conn, 42, {}) f1 = MethodFrame(1, 2, 3) f2 = MethodFrame(1, 2, 3) f3 = MethodFrame(1, 2, 3) c._pending_events = deque([f1, f2, 'cb', f3]) expect(conn.send_frame).args(f1) expect(conn.send_frame).args(f2) c._flush_pending_events() assert_equals(deque(['cb', f3]), c._pending_events)
def test_flush_pending_events_flushes_all_leading_frames(self): conn = mock() c = Channel(conn, 42, {}) f1 = MethodFrame(1, 2, 3) f2 = MethodFrame(1, 2, 3) f3 = MethodFrame(1, 2, 3) c._pending_events = deque([f1, f2, 'cb', f3]) expect(conn.send_frame).args(f1) expect(conn.send_frame).args(f2) c._flush_pending_events() assertEquals(deque(['cb', f3]), c._pending_events)
def test_closed_cb_without_final_frame(self): c = Channel(mock(), None, self._CLASS_MAP) c._pending_events = 'foo' c._frame_buffer = 'foo' for val in c._class_map.values(): expect(val._cleanup) expect(c._notify_close_listeners) c._closed_cb() assert_equals(deque([]), c._pending_events) assert_equals(deque([]), c._frame_buffer) assert_equals(None, c._connection) assert_false(hasattr(c, 'channel')) assert_false(hasattr(c, 'exchange')) assert_false(hasattr(c, 'queue')) assert_false(hasattr(c, 'basic')) assert_false(hasattr(c, 'tx')) assert_equals(None, c._class_map) assert_equals(set(), c._close_listeners)
def test_closed_cb_without_final_frame(self): c = Channel( "connection", None, {20: ChannelClass, 40: ExchangeClass, 50: QueueClass, 60: BasicClass, 90: TransactionClass}, ) c._pending_events = "foo" c._frame_buffer = "foo" for val in c._class_map.values(): expect(val._cleanup) expect(c._notify_close_listeners) c._closed_cb() assert_equals(deque([]), c._pending_events) assert_equals(deque([]), c._frame_buffer) assert_equals(None, c._connection) assert_false(hasattr(c, "channel")) assert_false(hasattr(c, "exchange")) assert_false(hasattr(c, "queue")) assert_false(hasattr(c, "basic")) assert_false(hasattr(c, "tx")) assert_equals(None, c._class_map) assert_equals(set(), c._close_listeners)