Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_is_service(self):
self.assertTrue(issubclass(
carbons_service.CarbonsClient,
aioxmpp.service.Service,
))
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)
def test_is_service(self):
self.assertTrue(issubclass(
private_xml_service.PrivateXMLService,
aioxmpp.service.Service
))
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(),
)
def setUp(self):
self.decorator = service.inbound_presence_filter
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,
)
def test_is_Service_subclass(self):
self.assertTrue(issubclass(
entitycaps_service.EntityCapsService,
service.Service
))
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
@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
# 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
)