2011-01-09 03:38:13 +00:00
|
|
|
import threading
|
|
|
|
|
2013-07-26 11:02:26 +00:00
|
|
|
import unittest
|
2014-07-17 12:19:04 +00:00
|
|
|
from slixmpp.test import SlixTest
|
2011-01-09 03:38:13 +00:00
|
|
|
|
|
|
|
|
2014-07-17 12:19:04 +00:00
|
|
|
class TestStreamSet(SlixTest):
|
2011-01-09 03:38:13 +00:00
|
|
|
|
|
|
|
def testHandleSoftwareVersionRequest(self):
|
|
|
|
self.stream_start(mode='client', plugins=['xep_0030', 'xep_0092'])
|
|
|
|
|
2014-07-17 12:19:04 +00:00
|
|
|
self.xmpp['xep_0092'].name = 'Slixmpp'
|
2011-01-09 03:38:13 +00:00
|
|
|
self.xmpp['xep_0092'].version = 'dev'
|
|
|
|
self.xmpp['xep_0092'].os = 'Linux'
|
|
|
|
|
|
|
|
self.recv("""
|
|
|
|
<iq type="get" id="1">
|
|
|
|
<query xmlns="jabber:iq:version" />
|
|
|
|
</iq>
|
|
|
|
""")
|
|
|
|
|
|
|
|
self.send("""
|
|
|
|
<iq type="result" id="1">
|
|
|
|
<query xmlns="jabber:iq:version">
|
2014-07-17 12:19:04 +00:00
|
|
|
<name>Slixmpp</name>
|
2011-01-09 03:38:13 +00:00
|
|
|
<version>dev</version>
|
|
|
|
<os>Linux</os>
|
|
|
|
</query>
|
|
|
|
</iq>
|
|
|
|
""")
|
|
|
|
|
|
|
|
def testMakeSoftwareVersionRequest(self):
|
|
|
|
results = []
|
|
|
|
|
2015-02-12 11:23:47 +00:00
|
|
|
def callback(result):
|
|
|
|
results.append((result['software_version']['name'],
|
|
|
|
result['software_version']['version'],
|
|
|
|
result['software_version']['os']))
|
2011-01-09 03:38:13 +00:00
|
|
|
|
|
|
|
self.stream_start(mode='client', plugins=['xep_0030', 'xep_0092'])
|
|
|
|
|
2015-02-12 11:23:47 +00:00
|
|
|
self.xmpp['xep_0092'].get_version('foo@bar', callback=callback)
|
2011-01-09 03:38:13 +00:00
|
|
|
|
|
|
|
self.send("""
|
|
|
|
<iq type="get" id="1" to="foo@bar">
|
|
|
|
<query xmlns="jabber:iq:version" />
|
|
|
|
</iq>
|
|
|
|
""")
|
|
|
|
|
|
|
|
self.recv("""
|
|
|
|
<iq type="result" id="1" from="foo@bar" to="tester@localhost">
|
|
|
|
<query xmlns="jabber:iq:version">
|
|
|
|
<name>Foo</name>
|
|
|
|
<version>1.0</version>
|
|
|
|
<os>Linux</os>
|
|
|
|
</query>
|
|
|
|
</iq>
|
|
|
|
""")
|
|
|
|
|
2013-01-21 00:08:01 +00:00
|
|
|
expected = [('Foo', '1.0', 'Linux')]
|
2011-01-09 03:38:13 +00:00
|
|
|
self.assertEqual(results, expected,
|
|
|
|
"Did not receive expected results: %s" % results)
|
|
|
|
|
|
|
|
|
|
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamSet)
|