def test_call_1(self): """ Test if the sessions call handler is called when an unidirectional call packet is received. """ conn = MockedConnection() chan = Channel(conn) conn.mock_connection_ready(True) session = chan.session('name') handler = Mock() session.add_call_handler(handler) conn.mock_downstream_verb(verbs.CallVerb( unidirectional=False, postref=1, name=b'name', payload=b'payload', )) self.__verify_handler_call( handler, Call, unidirectional=False, name='name', postref=1, payload='payload', )
def test_interest_2(self): """ Test if the sessions interest handler is called when an interest packet is received. """ conn = MockedConnection() chan = Channel(conn) conn.mock_connection_ready(True) session = chan.session('name') handler = Mock() session.add_interest_handler(handler) conn.mock_downstream_verb(verbs.InterestVerb( postref=1, name=b'name', status=verbs.InterestVerb.STATUS_NO_INTEREST, topic=b'topic' )) self.__verify_handler_call( handler, Interest, status=InterestStatus.NO_INTEREST, name='name', topic='topic', source=session, )
def test_login_logout_2(self): """ Test if both the login and logout verb are pushed when the connection becomes ready after the session is created. """ conn = MockedConnection() chan = Channel(conn) conn.mock_connection_ready(False) session = chan.session('name') conn.mock_connection_ready(True) conn.assert_upstream_verb(verbs.LoginVerb( name=b'name', enforce=False, standby=False, persist=False, )) session.cancel() conn.assert_upstream_verb(verbs.LogoutVerb( name=b'name', )) conn.assert_upstream_verb(None)
def test_login_logout_3(self): """ Test if no verbs are pushed at all if the session is created and canceled before the connection became ready. """ conn = MockedConnection() chan = Channel(conn) conn.mock_connection_ready(False) session = chan.session('name') session.cancel() conn.mock_connection_ready(True) conn.assert_upstream_verb(None)
def test_interest_connection_lost_1(self): """ Test if the interest is lost when the connection is lost. """ conn = MockedConnection() chan = Channel(conn) conn.mock_connection_ready(True) session = chan.session('name') handler = Mock() session.add_interest_handler(handler) conn.mock_downstream_verb(verbs.InterestVerb( postref=1, name=b'name', status=verbs.InterestVerb.STATUS_INTEREST, topic=b'topic' )) self.__verify_handler_call( handler, Interest, status=InterestStatus.INTEREST, topic='topic', source=session, ) conn.mock_connection_ready(False) self.__verify_handler_call( handler, Interest, status=InterestStatus.NO_INTEREST, topic='topic', source=session, )