コード例 #1
0
    def test_live_device_state_change(self):
        api = ConnectAPI()
        d = api.list_connected_devices().first()
        api.delete_device_subscriptions(d.id)

        # request the `manufacturer` field
        channel = channels.CurrentResourceValue(device_id=d.id, resource_path='/3/0/0')
        observer = api.subscribe(channel)
        value = observer.next().block(timeout=2)
        # should be, in this case, TLV
        self.assertEqual(b'6465765f6d616e756661637475726572', value)
コード例 #2
0
    def test_live_device_state_change(self):
        api = ConnectAPI()
        api.delete_presubscriptions()
        d = api.list_connected_devices().first()
        api.delete_device_subscriptions(d.id)
        channel = channels.ResourceValues(device_id=d.id,
                                          resource_path=['/3/0/*'])
        observer = api.subscribe(channel)
        # don't actually care about notifications, we want to see subscriptions
        current_subs = api.list_device_subscriptions(d.id)
        self.assertGreaterEqual(len(current_subs), 3)
        for path in current_subs:
            self.assertIn('/3/0', path)

        channel.stop()
        current_subs = api.list_device_subscriptions(d.id)
        self.assertIsNone(None, current_subs)