def test_subscribe_recursively_match_names(self): field1 = random_str(10) field2 = random_str(10) field3 = random_str(10) pub_topic = "%s/%s/%s" % (field1, field2,field3) sub_topic1 = "%s/#" % (field1) msg = "recursively_match_names_one" self.subscribe_client.subscribe(sub_topic1, self.handle_topic, 2) time.sleep(SYNC_WAIT_TIME) self.publish_client.publish(pub_topic, msg, 2) time.sleep(SYNC_WAIT_TIME) subscribe_client2 = MQTTClient() subscribe_client2.init(MQTT_IP, MQTT_PORT) subscribe_client2.start() time.sleep(SYNC_WAIT_TIME) sub_topic2 = "%s/%s/#" % (field1, field2) msg = "recursively_match_names__two" subscribe_client2.subscribe(sub_topic2, self.handle_topic, 2) time.sleep(SYNC_WAIT_TIME) self.publish_client.publish(pub_topic, msg, 2) time.sleep(SYNC_WAIT_TIME)
def test_subscribe_recursively_match_names(self): field1 = random_str(10) field2 = random_str(10) field3 = random_str(10) pub_topic = "%s/%s/%s" % (field1, field2,field3) sub_topic1 = "%s/#" % (field1) msg = "recursively_match_names_one" self.subscribe_client.subscribe(sub_topic1, self.handle_topic, 2) time.sleep(SYNC_WAIT_TIME) self.publish_client.publish(pub_topic, msg, 2) time.sleep(SYNC_WAIT_TIME) subscribe_client2 = MQTTClient() subscribe_client2.init(MQTT_IP, MQTT_PORT) subscribe_client2.start() time.sleep(SYNC_WAIT_TIME) sub_topic2 = "%s/%s/#" % (field1, field2) msg = "recursively_match_names__two" subscribe_client2.subscribe(sub_topic2, self.handle_topic, 2) time.sleep(SYNC_WAIT_TIME) self.publish_client.publish(pub_topic, msg, 2) time.sleep(SYNC_WAIT_TIME)
def test_subscribe_match_any_name(self): field1 = random_str(10) field2 = random_str(10) field3 = random_str(10) pub_topic = "%s/%s/%s" % (field1, field2,field3) sub_topic1 = "%s/+/%s" % (field1, field3) msg = "match_any_name_middle" self.subscribe_client.subscribe(sub_topic1, self.handle_topic, 2) time.sleep(SYNC_WAIT_TIME) self.publish_client.publish(pub_topic, msg, 2) time.sleep(SYNC_WAIT_TIME) subscribe_client2 = MQTTClient() subscribe_client2.init(MQTT_IP, MQTT_PORT) subscribe_client2.start() time.sleep(SYNC_WAIT_TIME) sub_topic2 = "%s/%s/+" % (field1, field2) msg = "match_any_name_right" subscribe_client2.subscribe(sub_topic2, self.handle_topic, 2) time.sleep(SYNC_WAIT_TIME) self.publish_client.publish(pub_topic, msg, 2) time.sleep(SYNC_WAIT_TIME) subscribe_client3 = MQTTClient() subscribe_client3.init(MQTT_IP, MQTT_PORT) subscribe_client3.start() time.sleep(SYNC_WAIT_TIME) sub_topic3 = "+/%s/%s" % (field2, field3) msg = "match_any_name_left" subscribe_client3.subscribe(sub_topic3, self.handle_topic, 2) time.sleep(SYNC_WAIT_TIME) self.publish_client.publish(pub_topic, msg, 2) time.sleep(SYNC_WAIT_TIME)
def test_subscribe_match_any_name(self): field1 = random_str(10) field2 = random_str(10) field3 = random_str(10) pub_topic = "%s/%s/%s" % (field1, field2,field3) sub_topic1 = "%s/+/%s" % (field1, field3) msg = "match_any_name_middle" self.subscribe_client.subscribe(sub_topic1, self.handle_topic, 2) time.sleep(SYNC_WAIT_TIME) self.publish_client.publish(pub_topic, msg, 2) time.sleep(SYNC_WAIT_TIME) subscribe_client2 = MQTTClient() subscribe_client2.init(MQTT_IP, MQTT_PORT) subscribe_client2.start() time.sleep(SYNC_WAIT_TIME) sub_topic2 = "%s/%s/+" % (field1, field2) msg = "match_any_name_right" subscribe_client2.subscribe(sub_topic2, self.handle_topic, 2) time.sleep(SYNC_WAIT_TIME) self.publish_client.publish(pub_topic, msg, 2) time.sleep(SYNC_WAIT_TIME) subscribe_client3 = MQTTClient() subscribe_client3.init(MQTT_IP, MQTT_PORT) subscribe_client3.start() time.sleep(SYNC_WAIT_TIME) sub_topic3 = "+/%s/%s" % (field2, field3) msg = "match_any_name_left" subscribe_client3.subscribe(sub_topic3, self.handle_topic, 2) time.sleep(SYNC_WAIT_TIME) self.publish_client.publish(pub_topic, msg, 2) time.sleep(SYNC_WAIT_TIME)