def test_invalid_subscription_masks(self): masks = ( '##', '++', '#/', '/#/+', '+#', '#+', '+#/', '#+/', '/+#', '/#+', 'sports+', 'sports#', '+sports', '#sports', 'sports/#/', 'sport/tennis#', 'sport#/tennis', '#sport/tennis', 'sport/#tennis', 'sport/tennis+', 'sport+/tennis', 'sport/+tennis', '+sport/tennis', '++/sport/tennis', 'sport/++/tennis', 'sport/tennis/++', '+++/sport/tennis', 'sport/+++/tennis', 'sport/tennis/+++', 'sport/tennis/#/ranking', 'sport/tennis/##/ranking', '#/sport/tennis/ranking', '##/sport/tennis/ranking', 'sport/tennis/ranking/##', 'sport/tennis/ranking/##/', ) for mask in masks: self.assertFalse(MQTTUtils.subscription_is_valid(mask), "%s is valid" % mask)
def test_valid_subscription_masks(self): masks = ( '', '#', 'foo/#', '1/data/#', '1/control/user/2', '1/control/user/+', '1/control/+/2', '+/control/+/2', '+/control/+/#', '1/control/devices/wtcsctnfZ-1-2', '+', '+/', '+/#', '+/+', '+/+/', '+/+/#', '/+', '/+/+', '/+/+/#', 'sport/tennis/player1', 'sport/tennis/player1/ranking', 'sport/tennis/player1/score/wimbledon', 'sport/#', 'sport/tennis/#', '+/tennis/#', 'sport/+/player1', 'sport/+/player1/#', '/', '//', '+//', '/+/', '//+', '/#', '//#', '+//#', '/+/#', '//+/#', ) for mask in masks: self.assertTrue(MQTTUtils.subscription_is_valid(mask), "%s is invalid" % mask)