How to use the opsdroid.connector.webexteams.ConnectorWebexTeams function in opsdroid

To help you get started, we’ve selected a few opsdroid 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 opsdroid / opsdroid / tests / test_connector_webexteams.py View on Github external
def test_init(self):
        """Test that the connector is initialised properly."""
        connector = ConnectorWebexTeams({})
        self.assertEqual("webexteams", connector.name)
        self.assertEqual("opsdroid", connector.bot_name)
github opsdroid / opsdroid / tests / test_connector_webexteams.py View on Github external
async def test_respond(self):
        connector = ConnectorWebexTeams({"token": "abc123"})
        connector.api = amock.CoroutineMock()
        connector.api.messages.create = amock.CoroutineMock()
        message = Message(
            text="Hello",
            user="opsdroid",
            target={"id": "3vABZrQgDzfcz7LZi"},
            connector=None,
        )
        await connector.send(message)
        self.assertTrue(connector.api.messages.create.called)
github opsdroid / opsdroid / tests / test_connector_webexteams.py View on Github external
async def test_connect(self):
        connector = ConnectorWebexTeams({"token": "abc123"}, opsdroid=OpsDroid())

        opsdroid = amock.CoroutineMock()
        opsdroid.eventloop = self.loop
        connector.clean_up_webhooks = amock.CoroutineMock()
        connector.subscribe_to_rooms = amock.CoroutineMock()
        connector.set_own_id = amock.CoroutineMock()

        with amock.patch("websockets.connect", new=amock.CoroutineMock()):
            await connector.connect()

        self.assertTrue(connector.clean_up_webhooks.called)
        self.assertTrue(connector.subscribe_to_rooms.called)
        self.assertTrue(connector.set_own_id.called)
github opsdroid / opsdroid / tests / test_connector_webexteams.py View on Github external
def test_missing_api_key(self):
        """Test that creating without an API without config raises an error."""
        with self.assertRaises(TypeError):
            ConnectorWebexTeams()
github opsdroid / opsdroid / tests / test_connector_webexteams.py View on Github external
async def test_connect_fail_keyerror(self):
        connector = ConnectorWebexTeams({}, opsdroid=OpsDroid())
        connector.clean_up_webhooks = amock.CoroutineMock()
        connector.subscribe_to_rooms = amock.CoroutineMock()
        connector.set_own_id = amock.CoroutineMock()
        await connector.connect()
        self.assertLogs("_LOGGER", "error")
github opsdroid / opsdroid / tests / test_connector_webexteams.py View on Github external
async def test_get_person(self):
        connector = ConnectorWebexTeams({"token": "abc123"})
        connector.api = amock.CoroutineMock()
        connector.api.messages.create = amock.CoroutineMock()
        connector.api.people.get = amock.CoroutineMock()
        connector.api.people.get.return_value = "Himanshu"
        self.assertEqual(len(connector.people), 0)
        await connector.get_person("3vABZrQgDzfcz7LZi")
        self.assertEqual(len(connector.people), 1)
github opsdroid / opsdroid / tests / test_connector_webexteams.py View on Github external
async def test_set_own_id(self):
        connector = ConnectorWebexTeams({"token": "abc123"})
        connector.api = amock.CoroutineMock()
        connector.api.people.me().id = "3vABZrQgDzfcz7LZi"
        await connector.set_own_id()
        self.assertTrue(connector.bot_webex_id, "3vABZrQgDzfcz7LZi")
github opsdroid / opsdroid / tests / test_connector_webexteams.py View on Github external
async def test_subscribe_to_rooms(self):
        connector = ConnectorWebexTeams(
            {"token": "abc123", "webhook-url": "http://127.0.0.1"}
        )
        connector.api = amock.CoroutineMock()
        connector.opsdroid = amock.CoroutineMock()
        connector.opsdroid.web_server.web_app.router.add_post = amock.CoroutineMock()
        connector.api.webhooks.create = amock.CoroutineMock()
        await connector.subscribe_to_rooms()
        self.assertTrue(connector.api.webhooks.create.called)
        self.assertTrue(connector.opsdroid.web_server.web_app.router.add_post.called)
github opsdroid / opsdroid / tests / test_connector_webexteams.py View on Github external
async def test_message_handler(self):
        connector = ConnectorWebexTeams({"token": "abc123"})
        connector.opsdroid = OpsDroid()
        connector.bot_spark_id = "spark123"
        connector.api = amock.CoroutineMock()
        request = amock.Mock()
        request.json = amock.CoroutineMock()
        request.json.return_value = {
            "data": {"id": "3vABZrQgDzfcz7LZi", "personId": "21ABZrQgDzfcz7Lsi"}
        }
        message = amock.Mock()
        connector.api.messages.get = amock.Mock()
        message.text = "Hello"
        message.roomId = "90ABCrWgrzfcz7LZi"
        message.roomType = "general"
        connector.api.messages.get.return_value = message
        connector.get_person = amock.CoroutineMock()
        person = amock.CoroutineMock()
github opsdroid / opsdroid / tests / test_connector_webexteams.py View on Github external
async def test_listen(self):
        """Test the listen method.

        The Webex Teams connector listens using an API endoint and so the listen
        method should just pass and do nothing. We just need to test that it
        does not block.

        """
        connector = ConnectorWebexTeams({}, opsdroid=OpsDroid())
        self.assertEqual(await connector.listen(), None)