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_reject_empty_localpart(self):
with self.assertRaises(ValueError):
structs.JID("", "bar.baz", None)
with self.assertRaises(ValueError):
structs.JID.fromstr("@bar.baz")
def test_bare(self):
j = structs.JID("foo", "example.test", "bar")
self.assertEqual(
structs.JID("foo", "example.test", None),
j.bare())
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")
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)
def test_reject_empty_domainpart(self):
with self.assertRaises(ValueError):
structs.JID("foo", "", None)
with self.assertRaises(ValueError):
structs.JID.fromstr("foo@")
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)
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 = '''\
'''
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")
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)
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):