def test_validate_topic(self): """Test topic name/filter validation.""" # Invalid UTF-8, must not contain U+D800 to U+DFFF. self.assertRaises(vol.Invalid, mqtt.valid_topic, '\ud800') self.assertRaises(vol.Invalid, mqtt.valid_topic, '\udfff') # Topic MUST NOT be empty self.assertRaises(vol.Invalid, mqtt.valid_topic, '') # Topic MUST NOT be longer than 65535 encoded bytes. self.assertRaises(vol.Invalid, mqtt.valid_topic, 'ü' * 32768) # UTF-8 MUST NOT include null character self.assertRaises(vol.Invalid, mqtt.valid_topic, 'bad\0one') # Topics "SHOULD NOT" include these special characters # (not MUST NOT, RFC2119). The receiver MAY close the connection. mqtt.valid_topic('\u0001') mqtt.valid_topic('\u001F') mqtt.valid_topic('\u009F') mqtt.valid_topic('\u009F') mqtt.valid_topic('\uffff')
def test_validate_topic(self): """Test topic name/filter validation.""" # Invalid UTF-8, must not contain U+D800 to U+DFFF. self.assertRaises(vol.Invalid, mqtt.valid_topic, '\ud800') self.assertRaises(vol.Invalid, mqtt.valid_topic, '\udfff') # Topic MUST NOT be empty self.assertRaises(vol.Invalid, mqtt.valid_topic, '') # Topic MUST NOT be longer than 65535 encoded bytes. self.assertRaises(vol.Invalid, mqtt.valid_topic, 'ü' * 32768) # UTF-8 MUST NOT include null character self.assertRaises(vol.Invalid, mqtt.valid_topic, 'bad\0one') # Topics "SHOULD NOT" include these special characters # (not MUST NOT, RFC2119). The receiver MAY close the connection. mqtt.valid_topic('\u0001') mqtt.valid_topic('\u001F') mqtt.valid_topic('\u009F') mqtt.valid_topic('\u009F') mqtt.valid_topic('\uffff')
def test_validate_topic(self): """Test topic name/filter validation.""" # Invalid UTF-8, must not contain U+D800 to U+DFFF. with pytest.raises(vol.Invalid): mqtt.valid_topic("\ud800") with pytest.raises(vol.Invalid): mqtt.valid_topic("\udfff") # Topic MUST NOT be empty with pytest.raises(vol.Invalid): mqtt.valid_topic("") # Topic MUST NOT be longer than 65535 encoded bytes. with pytest.raises(vol.Invalid): mqtt.valid_topic("ü" * 32768) # UTF-8 MUST NOT include null character with pytest.raises(vol.Invalid): mqtt.valid_topic("bad\0one") # Topics "SHOULD NOT" include these special characters # (not MUST NOT, RFC2119). The receiver MAY close the connection. mqtt.valid_topic("\u0001") mqtt.valid_topic("\u001F") mqtt.valid_topic("\u009F") mqtt.valid_topic("\u009F") mqtt.valid_topic("\uffff")