def get_char(self, name): """Return new Characteristic object.""" char_dict = self.char_types[name].copy() if ("Format" not in char_dict or "Permissions" not in char_dict or "UUID" not in char_dict): raise KeyError("Could not load char {}!".format(name)) return Characteristic.from_dict(name, char_dict, from_loader=True)
def get_char(self, name): """Return new Characteristic object.""" char_dict = self.char_types[name].copy() if 'Format' not in char_dict or \ 'Permissions' not in char_dict or \ 'UUID' not in char_dict: raise KeyError('Could not load char {}!'.format(name)) return Characteristic.from_dict(name, char_dict)
def test_from_dict(): """Test creating a characteristic object from a dictionary.""" uuid = uuid1() json_dict = { 'UUID': str(uuid), 'Format': 'int', 'Permissions': 'read', } char = Characteristic.from_dict('Test Char', json_dict) assert char.display_name == 'Test Char' assert char.type_id == uuid assert char.properties == {'Format': 'int', 'Permissions': 'read'}
def test_from_dict(): """Test creating a characteristic object from a dictionary.""" uuid = uuid1() json_dict = { "UUID": str(uuid), "Format": "int", "Permissions": "read", } char = Characteristic.from_dict("Test Char", json_dict) assert char.display_name == "Test Char" assert char.type_id == uuid assert char.properties == {"Format": "int", "Permissions": "read"}