How to use the aioxmpp.service function in aioxmpp

To help you get started, we’ve selected a few aioxmpp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github horazont / aioxmpp / tests / carbons / test_service.py View on Github external
def test_is_service(self):
        self.assertTrue(issubclass(
            carbons_service.CarbonsClient,
            aioxmpp.service.Service,
        ))
github horazont / aioxmpp / tests / test_node.py View on Github external
def test_summon(self):
        svc_init = unittest.mock.Mock()

        class Svc1(service.Service):
            def __init__(self, *args, **kwargs):
                super().__init__(*args, **kwargs)
                getattr(svc_init, type(self).__name__)(*args, **kwargs)

        class Svc2(service.Service):
            ORDER_BEFORE = [Svc1]

            def __init__(self, *args, **kwargs):
                super().__init__(*args, **kwargs)
                getattr(svc_init, type(self).__name__)(*args, **kwargs)

        class Svc3(service.Service):
            ORDER_BEFORE = [Svc2]

            def __init__(self, *args, **kwargs):
                super().__init__(*args, **kwargs)
github horazont / aioxmpp / tests / private_xml / test_service.py View on Github external
def test_is_service(self):
        self.assertTrue(issubclass(
            private_xml_service.PrivateXMLService,
            aioxmpp.service.Service
        ))
github horazont / aioxmpp / tests / test_service.py View on Github external
def test_forwards_to_dispatcher(self):
        with unittest.mock.patch(
                "aioxmpp.dispatcher."
                "is_presence_handler") as is_presence_handler:
            result = service.is_presence_handler(
                unittest.mock.sentinel.a1,
                unittest.mock.sentinel.a2,
                unittest.mock.sentinel.c,
            )

        is_presence_handler.assert_called_once_with(
            unittest.mock.sentinel.a1,
            unittest.mock.sentinel.a2,
            unittest.mock.sentinel.c,
        )

        self.assertEqual(
            result,
            is_presence_handler(),
        )
github horazont / aioxmpp / tests / test_service.py View on Github external
def setUp(self):
        self.decorator = service.inbound_presence_filter
github horazont / aioxmpp / tests / disco / test_service.py View on Github external
def test_handle_info_request_is_decorated(self):
        self.assertTrue(
            service.is_iq_handler(
                structs.IQType.GET,
                disco_xso.InfoQuery,
                disco_service.DiscoServer.handle_info_request,
            )
github horazont / aioxmpp / tests / entitycaps / test_service.py View on Github external
def test_is_Service_subclass(self):
        self.assertTrue(issubclass(
            entitycaps_service.EntityCapsService,
            service.Service
        ))
github horazont / aioxmpp / aioxmpp / dispatcher.py View on Github external
def decorator(f):
        if asyncio.iscoroutinefunction(f):
            raise TypeError(
                "presence_handler must not be a coroutine function"
            )

        aioxmpp.service.add_handler_spec(
            f,
            aioxmpp.service.HandlerSpec(
                (_apply_presence_handler, (type_, from_)),
                require_deps=(
                    SimplePresenceDispatcher,
                )
            )
        )
        return f
    return decorator
github horazont / aioxmpp / aioxmpp / ibb / service.py View on Github external
    @service.inbound_message_filter
    def _handle_message(self, msg):
        if msg.xep0047_data is None:
            return msg

        payload = msg.xep0047_data
        peer_jid = msg.from_
        sid = payload.sid

        try:
            session = self._sessions[sid, peer_jid]
        except KeyError:
            return None

        session._process_msg(payload)

        return None
github horazont / aioxmpp / aioxmpp / ping / service.py View on Github external
# License along with this program.  If not, see
# .
#
########################################################################
import asyncio

import aioxmpp.disco
import aioxmpp.service
import aioxmpp.structs

from aioxmpp.utils import namespaces

from . import xso as ping_xso


class PingService(aioxmpp.service.Service):
    """
    Service implementing XMPP Ping (:xep:`199`).

    This service implements the response to XMPP Pings and provides a method
    to send pings.

    .. automethod:: ping
    """

    ORDER_AFTER = [
        aioxmpp.disco.DiscoServer,
    ]

    _ping_feature = aioxmpp.disco.register_feature(
        namespaces.xep0199_ping
    )