summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-03-27 21:16:53 -0700
committerLance Stout <lancestout@gmail.com>2012-03-27 21:16:53 -0700
commitf1fde07eb9538fdce00ccf16cd34144feda69a58 (patch)
tree495a9dce312d23665e96383a781caa152c194bf2 /tests
parenta1ddd88208d4120db7210ca363e03116b376e3bf (diff)
downloadslixmpp-f1fde07eb9538fdce00ccf16cd34144feda69a58.tar.gz
slixmpp-f1fde07eb9538fdce00ccf16cd34144feda69a58.tar.bz2
slixmpp-f1fde07eb9538fdce00ccf16cd34144feda69a58.tar.xz
slixmpp-f1fde07eb9538fdce00ccf16cd34144feda69a58.zip
Add tests for bool_interfaces.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stanza_element.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_stanza_element.py b/tests/test_stanza_element.py
index f7ec59c0..60ccb7c9 100644
--- a/tests/test_stanza_element.py
+++ b/tests/test_stanza_element.py
@@ -742,5 +742,37 @@ class TestElementBase(SleekTest):
<foo xmlns="foo" bar="override-foo" />
""")
+ def testBoolInterfaces(self):
+ """Test using boolean interfaces."""
+
+ class TestStanza(ElementBase):
+ name = "foo"
+ namespace = "foo"
+ interfaces = set(['bar'])
+ bool_interfaces = interfaces
+
+ stanza = TestStanza()
+ self.check(stanza, """
+ <foo xmlns="foo" />
+ """)
+
+ self.assertFalse(stanza['bar'],
+ "Returned True for missing bool interface element.")
+
+ stanza['bar'] = True
+ self.check(stanza, """
+ <foo xmlns="foo">
+ <bar />
+ </foo>
+ """)
+
+ self.assertTrue(stanza['bar'],
+ "Returned False for present bool interface element.")
+
+ stanza['bar'] = False
+ self.check(stanza, """
+ <foo xmlns="foo" />
+ """)
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestElementBase)