예제 #1
0
    async def test_unsubscribe(self):
        r = UpnpTestRequester(RESPONSE_MAP)
        factory = UpnpFactory(r)
        device = await factory.async_create_device('http://localhost:1234/dmr')
        event_handler = UpnpEventHandler('http://localhost:11302', r)

        service = device.service(
            'urn:schemas-upnp-org:service:RenderingControl:1')
        await event_handler.async_subscribe(service)
        assert event_handler.service_for_sid('uuid:dummy') == service

        await event_handler.async_unsubscribe(service)
        assert event_handler.service_for_sid('uuid:dummy') is None
예제 #2
0
    async def test_unsubscribe(self):
        """Test unsubscribing from a UpnpService."""
        requester = UpnpTestRequester(RESPONSE_MAP)
        factory = UpnpFactory(requester)
        device = await factory.async_create_device("http://localhost:1234/dmr")
        event_handler = UpnpEventHandler("http://localhost:11302", requester)

        service = device.service(
            "urn:schemas-upnp-org:service:RenderingControl:1")
        success, sid = await event_handler.async_subscribe(service)
        assert event_handler.service_for_sid("uuid:dummy") == service
        assert success is True
        assert sid == "uuid:dummy"

        success, old_sid = await event_handler.async_unsubscribe(service)
        assert event_handler.service_for_sid("uuid:dummy") is None
        assert success is True
        assert old_sid == "uuid:dummy"
예제 #3
0
    async def test_subscribe_renew(self):
        """Test renewing an existing subscription to a UpnpService."""
        requester = UpnpTestRequester(RESPONSE_MAP)
        factory = UpnpFactory(requester)
        device = await factory.async_create_device("http://localhost:1234/dmr")
        event_handler = UpnpEventHandler("http://localhost:11302", requester)

        service = device.service(
            "urn:schemas-upnp-org:service:RenderingControl:1")
        success, sid, timeout = await event_handler.async_subscribe(service)
        assert success is True
        assert sid == "uuid:dummy"
        assert event_handler.service_for_sid("uuid:dummy") == service
        assert timeout == timedelta(seconds=300)

        success, sid, timeout = await event_handler.async_resubscribe(service)
        assert event_handler.service_for_sid("uuid:dummy") == service
        assert success is True
        assert sid == "uuid:dummy"
        assert timeout == timedelta(seconds=300)