예제 #1
0
    async def test_process_callback(self):
        """Test setting value. Test if callback is called."""

        xknx = XKNX()
        after_update_callback = AsyncMock()
        expose_sensor = ExposeSensor(xknx,
                                     "TestSensor",
                                     group_address="1/2/3",
                                     value_type="temperature")
        expose_sensor.register_device_updated_cb(after_update_callback)

        await expose_sensor.set(21.0)
        await xknx.devices.process(xknx.telegrams.get_nowait())
        after_update_callback.assert_called_with(expose_sensor)
예제 #2
0
    def test_process_callback(self):
        """Test setting value. Test if callback is called."""
        # pylint: disable=no-self-use
        xknx = XKNX(loop=self.loop)
        expose_sensor = ExposeSensor(xknx,
                                     'TestSensor',
                                     group_address='1/2/3',
                                     value_type="temperature")

        after_update_callback = Mock()

        async def async_after_update_callback(device):
            """Async callback."""
            after_update_callback(device)

        expose_sensor.register_device_updated_cb(async_after_update_callback)

        self.loop.run_until_complete(asyncio.Task(expose_sensor.set(21.0)))
        after_update_callback.assert_called_with(expose_sensor)
예제 #3
0
    def test_process_callback(self):
        """Test setting value. Test if callback is called."""
        # pylint: disable=no-self-use
        xknx = XKNX()
        expose_sensor = ExposeSensor(
            xknx, "TestSensor", group_address="1/2/3", value_type="temperature"
        )

        after_update_callback = Mock()

        async def async_after_update_callback(device):
            """Async callback."""
            after_update_callback(device)

        expose_sensor.register_device_updated_cb(async_after_update_callback)

        self.loop.run_until_complete(expose_sensor.set(21.0))
        self.loop.run_until_complete(xknx.devices.process(xknx.telegrams.get_nowait()))
        after_update_callback.assert_called_with(expose_sensor)
예제 #4
0
    def test_process_callback(self):
        """Test setting value. Test if callback is called."""
        # pylint: disable=no-self-use
        xknx = XKNX(loop=self.loop)
        expose_sensor = ExposeSensor(
            xknx,
            'TestSensor',
            group_address='1/2/3',
            value_type="temperature")

        after_update_callback = Mock()

        async def async_after_update_callback(device):
            """Async callback."""
            after_update_callback(device)
        expose_sensor.register_device_updated_cb(async_after_update_callback)

        self.loop.run_until_complete(asyncio.Task(expose_sensor.set(21.0)))
        after_update_callback.assert_called_with(expose_sensor)