Exemplo n.º 1
0
 def test_get_properties(self, eth0_file_mock):
     variant_details = variant_definitions['NEBHNT-OUT1']
     advertisement = BluetoothConnectionAdvertisement(
         110, 'A1:B2:C3:DD:E5:F6', 'peripheral', variant_details)
     properties = advertisement.get_properties()
     expected = {
         'org.bluez.LEAdvertisement1': {
             'Type':
             'peripheral',
             'IncludeTxPower':
             dbus.Boolean(True),
             'LocalName':
             dbus.String('Nebra %s Hotspot %s' % ('Outdoor', 'DDE5F6')),
             'ServiceUUIDs':
             dbus.Array([DEFAULT_SERVICE_UUID],
                        signature=dbus.Signature('s'))
         }
     }
     self.assertDictEqual(properties, expected)
Exemplo n.º 2
0
    def test_get_properties_extended(self):
        variant_details = variant_definitions['NEBHNT-OUT1']
        advertisement = BluetoothConnectionAdvertisement(
            115, 'A1:B2:C3:DD:E5:F6', "peripheral", variant_details)

        service_uuids = [str(uuid.uuid4())]
        advertisement.service_uuids = service_uuids
        advertisement.local_name = 'Local Name'
        solicit_uuids = [str(uuid.uuid4())]
        advertisement.solicit_uuids = solicit_uuids
        manufacturer_data = {'hello': 'manufacturer'}
        advertisement.manufacturer_data = manufacturer_data
        service_data = {'hello': 'service'}
        advertisement.service_data = service_data
        advertisement.include_tx_power = True

        properties = advertisement.get_properties()
        expected = {
            'org.bluez.LEAdvertisement1': {
                'IncludeTxPower':
                dbus.Boolean(True),
                'LocalName':
                dbus.String('Local Name'),
                'ManufacturerData':
                manufacturer_data,
                'ServiceData':
                service_data,
                'ServiceUUIDs':
                dbus.Array(service_uuids, signature=dbus.Signature('s')),
                'SolicitUUIDs':
                dbus.Array(solicit_uuids, signature=dbus.Signature('s')),
                'Type':
                'peripheral'
            }
        }
        self.assertDictEqual(properties, expected)