How to use the aioxmpp.structs.JID 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 / test_structs.py View on Github external
def test_reject_empty_localpart(self):
        with self.assertRaises(ValueError):
            structs.JID("", "bar.baz", None)
        with self.assertRaises(ValueError):
            structs.JID.fromstr("@bar.baz")
github horazont / aioxmpp / tests / test_structs.py View on Github external
def test_bare(self):
        j = structs.JID("foo", "example.test", "bar")
        self.assertEqual(
            structs.JID("foo", "example.test", None),
            j.bare())
github horazont / aioxmpp / tests / test_node.py View on Github external
self.assertEqual(
            client.backoff_factor,
            1.2
        )

        self.assertEqual(client.on_stopped.logger,
                         client._logger.getChild("on_stopped"))
        self.assertEqual(client.on_failure.logger,
                         client._logger.getChild("on_failure"))
        self.assertEqual(client.on_stream_established.logger,
                         client._logger.getChild("on_stream_established"))
        self.assertEqual(client.on_stream_destroyed.logger,
                         client._logger.getChild("on_stream_destroyed"))

        with self.assertRaises(AttributeError):
            client.local_jid = structs.JID.fromstr("bar@bar.example/baz")
github horazont / aioxmpp / tests / test_structs.py View on Github external
def test_init_without_strict_does_not_error_on_unassigned(self):
        structs.JID("\U0001f601", "example.com", "bar", strict=False)
        structs.JID("foo", "\U0001f601example.com", "bar", strict=False)
        structs.JID("foo", "example.com", "\U0001f601", strict=False)
github horazont / aioxmpp / tests / test_structs.py View on Github external
def test_reject_empty_domainpart(self):
        with self.assertRaises(ValueError):
            structs.JID("foo", "", None)
        with self.assertRaises(ValueError):
            structs.JID.fromstr("foo@")
github horazont / aioxmpp / tests / test_structs.py View on Github external
def test_reject_long_domainpart(self):
        with self.assertRaisesRegex(ValueError, "too long"):
            structs.JID(None, "x"*1024, None)
        with self.assertRaisesRegex(ValueError, "too long"):
            structs.JID(None, "ü"*512, None)
        with self.assertRaisesRegex(ValueError, "too long"):
            structs.JID.fromstr("ü"*512)
github horazont / aioxmpp / tests / test_highlevel.py View on Github external
import asyncio
import unittest

from datetime import timedelta

import aioxmpp.structs

from aioxmpp.testutils import (
    TransportMock,
    run_coroutine,
    run_coroutine_with_peer
)


TEST_FROM = aioxmpp.structs.JID.fromstr("foo@bar.example")
TEST_PEER = aioxmpp.structs.JID.fromstr("bar.example")

STREAM_HEADER = b'''\
\
'''

PEER_STREAM_HEADER_TEMPLATE = '''\
'''
github horazont / aioxmpp / tests / test_structs.py View on Github external
def test_reject_long_localpart(self):
        with self.assertRaisesRegex(ValueError, "too long"):
            structs.JID("x"*1024, "foo", None)
        with self.assertRaisesRegex(ValueError, "too long"):
            structs.JID("ü"*512, "foo", None)
        with self.assertRaisesRegex(ValueError, "too long"):
            structs.JID.fromstr("ü"*512 + "@foo")
github horazont / aioxmpp / tests / test_structs.py View on Github external
def test_init_enforces_stringprep(self):
        with self.assertRaises(ValueError):
            structs.JID("\u0007", "example.com", "bar")
        with self.assertRaises(ValueError):
            structs.JID("foo", "\u070f", "bar")
        with self.assertRaises(ValueError):
            structs.JID("foo", "example.com", "\u0007")

        self.assertEqual(
            "ssa",
            structs.JID("ßA", "example.test", None).localpart)

        self.assertEqual(
            "ix.test",
            structs.JID(None, "IX.test", None).domain)

        self.assertEqual(
            "IX",
            structs.JID(None, "example.test", "\u2168").resource)
github horazont / aioxmpp / tests / pubsub / test_service.py View on Github external
import aioxmpp.stanza
import aioxmpp.structs
import aioxmpp.pubsub.service as pubsub_service
import aioxmpp.pubsub.xso as pubsub_xso

from aioxmpp.testutils import (
    make_connected_client,
    CoroutineMock,
    run_coroutine,
)


TEST_FROM = aioxmpp.structs.JID.fromstr("foo@bar.example/baz")
TEST_JID1 = aioxmpp.structs.JID.fromstr("bar@bar.example/baz")
TEST_JID2 = aioxmpp.structs.JID.fromstr("baz@bar.example/baz")
TEST_JID3 = aioxmpp.structs.JID.fromstr("fnord@bar.example/baz")
TEST_TO = aioxmpp.structs.JID.fromstr("pubsub.example")


@pubsub_xso.as_payload_class
class SomePayload(aioxmpp.xso.XSO):
    TAG = "aioxmpp.tests.pubsub.test_service", "foo"


class TestService(unittest.TestCase):
    def test_is_service(self):
        self.assertTrue(issubclass(
            pubsub_service.PubSubClient,
            aioxmpp.service.Service
        ))

    def test_orders_behind_disco(self):