diff options
author | Lance Stout <lancestout@gmail.com> | 2010-08-19 20:41:26 -0400 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2010-08-19 20:41:26 -0400 |
commit | 8a0616b3e0c9b5b79ce9418a2494303b28863b4b (patch) | |
tree | cc652c9ad3505b60a0aae9f94a3435d203eb8a68 /tests | |
parent | b71cfe049285bf777b0e648cebb05c7da6c69e44 (diff) | |
download | slixmpp-8a0616b3e0c9b5b79ce9418a2494303b28863b4b.tar.gz slixmpp-8a0616b3e0c9b5b79ce9418a2494303b28863b4b.tar.bz2 slixmpp-8a0616b3e0c9b5b79ce9418a2494303b28863b4b.tar.xz slixmpp-8a0616b3e0c9b5b79ce9418a2494303b28863b4b.zip |
Updated ElementBase methods _getAttr, _setAttr, and _delAttr with docs and tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_elementbase.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_elementbase.py b/tests/test_elementbase.py index bf86e599..78277af4 100644 --- a/tests/test_elementbase.py +++ b/tests/test_elementbase.py @@ -231,4 +231,41 @@ class TestElementBase(SleekTest): <foo xmlns="foo" qux="c" /> """) + def testModifyingAttributes(self): + """Test modifying top level attributes of a stanza's XML object.""" + + class TestStanza(ElementBase): + name = "foo" + namespace = "foo" + interfaces = set(('bar', 'baz')) + + stanza = TestStanza() + + self.checkStanza(TestStanza, stanza, """ + <foo xmlns="foo" /> + """) + + self.failUnless(stanza._getAttr('bar') == '', + "Incorrect value returned for an unset XML attribute.") + + stanza._setAttr('bar', 'a') + stanza._setAttr('baz', 'b') + + self.checkStanza(TestStanza, stanza, """ + <foo xmlns="foo" bar="a" baz="b" /> + """) + + self.failUnless(stanza._getAttr('bar') == 'a', + "Retrieved XML attribute value is incorrect.") + + stanza._setAttr('bar', None) + stanza._delAttr('baz') + + self.checkStanza(TestStanza, stanza, """ + <foo xmlns="foo" /> + """) + + self.failUnless(stanza._getAttr('bar', 'c') == 'c', + "Incorrect default value returned for an unset XML attribute.") + suite = unittest.TestLoader().loadTestsFromTestCase(TestElementBase) |