Beispiel #1
0
    def test_parse_var_string_replacers(self):
        input_str = ''
        output_str = ''
        for invalid_char, replacement_char in CHARACTER_REPLACE_MAP.items():
            input_str += replacement_char
            output_str += invalid_char

        self.assertEqual(utils.parse_var_string(f'test={input_str}'), {'test': output_str})
Beispiel #2
0
    def __init__(self, from_dict=None):
        self.command = from_dict.get('command')
        self.result = from_dict.get('result')
        self.message = from_dict.get('message')

        self.vars = {}
        if self.message:  # Extract variables from the message string for ease-of-access
            self.vars = utils.parse_var_string(self.message)
Beispiel #3
0
    def __init__(self, source: Union[dict, list] = None):
        self.data = source
        self.vars = {}

        if source and isinstance(source, dict):
            message = source.get('message')
            if message:
                self.vars = utils.parse_var_string(message)
Beispiel #4
0
    def __init__(self, from_dict: dict = None):
        if from_dict:
            heos = from_dict.get('heos', {})

            self.command = heos.get('command')
            self.message = heos.get('message')
            self.raw = json.dumps(from_dict)

            # Bind any message variables to our self as attributes
            self.vars = {}
            if self.message:
                self.vars = utils.parse_var_string(self.message)
Beispiel #5
0
 def test_parse_var_string(self):
     self.assertEqual(utils.parse_var_string('pid=12345678&un=someone'), {'pid': '12345678', 'un': 'someone'})
     self.assertEqual(utils.parse_var_string('signed_in&un=username'), {'signed_in': 'signed_in', 'un': 'username'})