From f1fde07eb9538fdce00ccf16cd34144feda69a58 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 27 Mar 2012 21:16:53 -0700 Subject: [PATCH] Add tests for bool_interfaces. --- tests/test_stanza_element.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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): """) + 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, """ + + """) + + self.assertFalse(stanza['bar'], + "Returned True for missing bool interface element.") + + stanza['bar'] = True + self.check(stanza, """ + + + + """) + + self.assertTrue(stanza['bar'], + "Returned False for present bool interface element.") + + stanza['bar'] = False + self.check(stanza, """ + + """) + suite = unittest.TestLoader().loadTestsFromTestCase(TestElementBase)