File: test_component.py

package info (click to toggle)
slixmpp 1.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,520 kB
  • sloc: python: 41,715; xml: 1,197; makefile: 120
file content (34 lines) | stat: -rw-r--r-- 1,100 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import unittest

from slixmpp.componentxmpp import ComponentXMPP
from slixmpp import JID

IN_CI = os.getenv('CI') == 'woodpecker'


class SlixComponentIntegration(unittest.IsolatedAsyncioTestCase):
    async def asyncSetUp(self):
        self.component = ComponentXMPP(CI_JID, CI_SECRET, CI_SERVER, CI_PORT)
        self.component.register_plugin("xep_0199")
        await self.component.connect()
        await self.component.wait_until("session_start")

    async def asyncTearDown(self):
        self.component.abort()

    @unittest.skipIf(not IN_CI, "Not in woodpecker CI")
    async def test_ping(self):
        """Check that a component can connect and send a ping to the server"""
        jid = JID(f"whatever@{CI_JID}")
        iq_pong = await self.component.plugin["xep_0199"].send_ping(JID(CI_SERVER), ifrom=jid)
        self.assertEqual(iq_pong["type"], "result")
        self.assertEqual(iq_pong.get_to(), jid)


CI_JID = "slixmpp.prosody"
CI_SECRET = "secret"
CI_SERVER = "prosody"
CI_PORT = 5347

suite = unittest.TestLoader().loadTestsFromTestCase(SlixComponentIntegration)