Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
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'}
Exemplo n.º 4
0
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"}