Add tests for bool_interfaces.
This commit is contained in:
parent
a1ddd88208
commit
f1fde07eb9
1 changed files with 32 additions and 0 deletions
|
@ -742,5 +742,37 @@ class TestElementBase(SleekTest):
|
||||||
<foo xmlns="foo" bar="override-foo" />
|
<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)
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestElementBase)
|
||||||
|
|
Loading…
Reference in a new issue