def test_bind_without_debugging(self): sock = EventSocket() sock._sock = mock() mock(sock, 'getsockname') expect(sock._sock.bind).args( 'arg1', 'arg2' ) expect(sock.getsockname).returns( ('foo',1234) ) expect(eventsocket.event.read).args( sock, sock._protected_cb, sock._accept_cb ) sock.bind( 'arg1', 'arg2' )
def test_bind_with_debugging(self): sock = EventSocket() sock._sock = mock() sock._debug = True sock._logger = mock() mock( sock, 'getsockname' ) expect(sock._logger.debug).args( "binding to %s", str(('arg1','arg2')) ) expect(sock._sock.bind).args( 'arg1', 'arg2' ) expect(sock.getsockname).returns( ('foo',1234) ) expect(eventsocket.event.read).args( sock, sock._protected_cb, sock._accept_cb ).returns('accept_event') sock.bind( 'arg1', 'arg2' ) assert_equals( "foo:1234", sock._peername ) assert_equals( 'accept_event', sock._accept_event )