1 from sleekxmpp
.test
import *
2 from sleekxmpp
.xmlstream
.stanzabase
import ET
5 class TestIqStanzas(SleekTest
):
8 """Shutdown the XML stream after testing."""
12 """Test initializing default Iq values."""
18 def testPayload(self
):
19 """Test setting Iq stanza payload."""
21 iq
.setPayload(ET
.Element('{test}tester'))
24 <tester xmlns="test" />
26 """, use_values
=False)
29 def testUnhandled(self
):
30 """Test behavior for Iq.unhandled."""
33 <iq id="test" type="get">
34 <query xmlns="test" />
40 iq
['error']['condition'] = 'feature-not-implemented'
41 iq
['error']['text'] = 'No handlers registered for this request.'
44 <iq id="test" type="error">
46 <feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
47 <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">
48 No handlers registered for this request.
55 """Test modifying query element of Iq stanzas."""
58 iq
['query'] = 'query_ns'
61 <query xmlns="query_ns" />
65 iq
['query'] = 'query_ns2'
68 <query xmlns="query_ns2" />
72 self
.failUnless(iq
['query'] == 'query_ns2', "Query namespace doesn't match")
80 """Test setting proper result type in Iq replies."""
82 iq
['to'] = 'user@localhost'
87 <iq id="0" type="result" />
90 suite
= unittest
.TestLoader().loadTestsFromTestCase(TestIqStanzas
)