def test_canOpenNewConnection_receiver(self): server = SMPPServerFactory(self.config, None) can_bind = server.canOpenNewConnection('lala', pdu_types.CommandId.bind_transceiver) self.assertTrue(can_bind, 'Should be able to bind trx as none bound yet') can_bind = server.canOpenNewConnection('lala', pdu_types.CommandId.bind_transmitter) self.assertTrue(can_bind, 'Should be able to bind tx as none bound yet') can_bind = server.canOpenNewConnection('lala', pdu_types.CommandId.bind_receiver) self.assertTrue(can_bind, 'Should be able to bind rx as none bound yet') mk_server_cnxn = _makeMockServerConnection('lala', pdu_types.CommandId.bind_receiver) server.addBoundConnection(mk_server_cnxn) can_bind = server.canOpenNewConnection('lala', pdu_types.CommandId.bind_transceiver) self.assertTrue(can_bind, 'Should still be able to bind as only one rx bound') can_bind = server.canOpenNewConnection('lala', pdu_types.CommandId.bind_transmitter) self.assertTrue(can_bind, 'Should still be able to bind only bindings are rx') can_bind = server.canOpenNewConnection('lala', pdu_types.CommandId.bind_receiver) self.assertTrue(can_bind, 'Should still be able to bind as only one rx bound') mk_server_cnxn = _makeMockServerConnection('lala', pdu_types.CommandId.bind_receiver) server.addBoundConnection(mk_server_cnxn) can_bind = server.canOpenNewConnection('lala', pdu_types.CommandId.bind_transceiver) self.assertFalse(can_bind, 'Should not be able to bind as two rx already bound') # NOTE this one different can_bind = server.canOpenNewConnection('lala', pdu_types.CommandId.bind_transmitter) self.assertTrue(can_bind, 'Should still be able to bind only bindings are rx') can_bind = server.canOpenNewConnection('lala', pdu_types.CommandId.bind_receiver) self.assertFalse(can_bind, 'Should not be able to bind as two rx already bound')