How to use the aioxmpp.JID.fromstr 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 / mix / xso / test_pam0.py View on Github external
# You should have received a copy of the GNU Lesser General Public
# License along with this program.  If not, see
# .
#
########################################################################
import unittest

import aioxmpp
import aioxmpp.xso as xso
import aioxmpp.mix.xso.core0 as core0_xso
import aioxmpp.mix.xso.pam0 as pam0_xso

from aioxmpp.utils import namespaces


TEST_JID = aioxmpp.JID.fromstr("channel@service")


class TestClientJoin0(unittest.TestCase):
    def test_is_xso(self):
        self.assertTrue(issubclass(
            pam0_xso.ClientJoin0,
            xso.XSO,
        ))

    def test_tag(self):
        self.assertEqual(
            pam0_xso.ClientJoin0.TAG,
            (namespaces.xep0405_mix_pam_0, "client-join"),
        )

    def test_channel(self):
github horazont / aioxmpp / tests / ping / test_service.py View on Github external
########################################################################
import unittest

import aioxmpp.disco
import aioxmpp.service

import aioxmpp.ping.service as ping_service
import aioxmpp.ping.xso as ping_xso

from aioxmpp.testutils import (
    make_connected_client,
    run_coroutine,
)


TEST_PEER = aioxmpp.JID.fromstr("juliet@capulet.lit/balcony")


class TestService(unittest.TestCase):
    def setUp(self):
        self.cc = make_connected_client()
        self.disco_server = unittest.mock.Mock()
        self.s = ping_service.PingService(self.cc, dependencies={
            aioxmpp.DiscoServer: self.disco_server
        })

    def test_is_service(self):
        self.assertTrue(issubclass(
            ping_service.PingService,
            aioxmpp.service.Service,
        ))
github horazont / aioxmpp / tests / adhoc / test_service.py View on Github external
import aioxmpp.service

import aioxmpp.adhoc.service as adhoc_service
import aioxmpp.adhoc.xso as adhoc_xso
import aioxmpp.disco

from aioxmpp.utils import namespaces

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


TEST_PEER_JID = aioxmpp.JID.fromstr("foo@bar.baz/fnord")
TEST_LOCAL_JID = aioxmpp.JID.fromstr("bar@bar.baz/fnord")


class TestAdHocClient(unittest.TestCase):
    def setUp(self):
        self.cc = make_connected_client()
        self.disco_service = unittest.mock.Mock()
        self.disco_service.query_info = CoroutineMock()
        self.disco_service.query_info.side_effect = AssertionError()
        self.disco_service.query_items = CoroutineMock()
        self.disco_service.query_items.side_effect = AssertionError()
        self.c = adhoc_service.AdHocClient(
            self.cc,
            dependencies={
                aioxmpp.disco.DiscoClient: self.disco_service,
            }
github horazont / aioxmpp / aioxmpp / e2etest / provision.py View on Github external
def configure_blockmap(section):
    blockmap_raw = ast.literal_eval(section.get("block_features",
                                                fallback="{}"))
    return {
        aioxmpp.JID.fromstr(entity): features
        for entity, features in blockmap_raw.items()
    }
github horazont / aioxmpp / tests / forms / test_form.py View on Github external
)

            something_else = fields.TextSingle(
                var="other",
                label="Something else",
            )

            LAYOUT = [
                "Metadata",
                jid,
                "Captcha",
                something_else,
            ]

        f = F()
        f.jid.value = aioxmpp.JID.fromstr("foo@bar.baz")
        f.something_else.value = "some_text"

        data = f.render_request()

        self.assertIsInstance(
            data,
            forms_xso.Data,
        )

        self.assertEqual(
            len(data.fields),
            4
        )

        for field in data.fields:
            self.assertIsInstance(
github horazont / aioxmpp / tests / forms / test_fields.py View on Github external
import abc
import collections
import contextlib
import copy
import itertools
import unittest
import unittest.mock

import aioxmpp
import aioxmpp.xso as xso

import aioxmpp.forms.fields as fields
import aioxmpp.forms.xso as forms_xso


TEST_JID = aioxmpp.JID.fromstr("foo@bar.baz/fnord")


def instance_mock():
    mock = unittest.mock.Mock()
    mock._descriptor_data = {}
    return mock


def generate_values(prefix):
    i = 0
    while True:
        yield getattr(unittest.mock.sentinel, prefix + str(i))
        i += 1


class TestBoundField(unittest.TestCase):
github horazont / muchopper / muchopper / bot / mirror.py View on Github external
def _on_item_published(self, jid, node, item, **kwargs):
        if (jid != self.source or
                node != xso.StateTransferV1_0Namespaces.MUCS.value):
            self.logger.debug(
                "ignoring update from invalid source: %s (node %r)",
                jid,
                node,
            )
            return

        if self._state is None:
            self.logger.warning("lost update: state is not ready yet")
            return

        address = aioxmpp.JID.fromstr(item.id_)
        self.logger.debug("received update for %s", address)
        data = item.registered_payload
        self._unwrap_item_into_state(data, self._state)
github horazont / aioxmpp / examples / muc_logger.py View on Github external
def configure(self):
        super().configure()

        self.language_selectors = [
            self.args.language,
            aioxmpp.structs.LanguageRange.fromstr("*")
        ]

        self.muc_jid = self.args.muc
        if self.muc_jid is None:
            try:
                self.muc_jid = aioxmpp.JID.fromstr(
                    self.config.get("muc_logger", "muc_jid")
                )
            except (configparser.NoSectionError,
                    configparser.NoOptionError):
                self.muc_jid = aioxmpp.JID.fromstr(
                    input("MUC JID> ")
                )

        self.muc_nick = self.args.nick
        if self.muc_nick is None:
            try:
                self.muc_nick = self.config.get("muc_logger", "nick")
            except (configparser.NoSectionError,
                    configparser.NoOptionError):
                self.muc_nick = input("Nickname> ")