def test_connect_disconnect(connect_msg, msg_id, topic, connection_cmd, mode): def mock_pub(payload): assert payload == connect_msg if connection_cmd == 'CONNECT': connect(msg_id=msg_id, mode=mode, feature='meow', topic=topic, pub=mock_pub) elif connection_cmd == 'DISCONNECT': disconnect(msg_id=msg_id, mode=mode, feature='meow', topic=topic, pub=mock_pub)
def _add_link(self, id_, mode, feature, payload): ''' :param id_: the ``UUID`` object :param mode: ``idf`` or ``odf`` :param feature: the feature name :param payload: the full payload .. todo:: - Speed up special case: If there is no any function and only *one* IDF, we just bind to ``esm_fixed_topic`` in order to do direct data transfer. ''' # FIXME: pub can be none, if da do not register pub = iot_conn_mgr.conns[id_].ctrl.pub msg_id = str(uuid4()) # random topic = self.esm_topic iot_conn_mgr.conns[id_].ctrl.add_res_callback( msg_id, *self.response_func( payload, on_success=self._add_link_on_success(topic), on_error=None)) return ctrl.connect(msg_id, mode, feature, topic, pub)