summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sleekxmpp/stanza/presence.py12
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py4
-rw-r--r--tests/__init__.py0
-rw-r--r--tests/test_stanza_element.py6
-rw-r--r--tests/test_stanza_error.py8
-rw-r--r--tests/test_stanza_gmail.py2
6 files changed, 23 insertions, 9 deletions
diff --git a/sleekxmpp/stanza/presence.py b/sleekxmpp/stanza/presence.py
index 651bf34d..7eb0c5b1 100644
--- a/sleekxmpp/stanza/presence.py
+++ b/sleekxmpp/stanza/presence.py
@@ -78,7 +78,9 @@ class Presence(RootStanza):
Arguments:
show -- Must be one of: away, chat, dnd, or xa.
"""
- if show in self.showtypes:
+ if show is None:
+ self._delSub('show')
+ elif show in self.showtypes:
self._setSubText('show', text=show)
return self
@@ -99,6 +101,14 @@ class Presence(RootStanza):
self['show'] = value
return self
+ def delType(self):
+ """
+ Remove both the type attribute and the <show> element.
+ """
+ self._delAttr('type')
+ self._delSub('show')
+
+
def setPriority(self, value):
"""
Set the entity's priority value. Some server use priority to
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index f4a7e506..6851333f 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -423,7 +423,9 @@ class ElementBase(object):
self._delAttr(attrib)
elif attrib in self.plugin_attrib_map:
if attrib in self.plugins:
+ xml = self.plugins[attrib].xml
del self.plugins[attrib]
+ self.xml.remove(xml)
return self
def _setAttr(self, name, value):
@@ -511,7 +513,7 @@ class ElementBase(object):
element = self.xml.find(name)
if not text and not keep:
- return self.__delitem__(name)
+ return self._delSub(name)
if element is None:
# We need to add the element. If the provided name was
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/__init__.py
diff --git a/tests/test_stanza_element.py b/tests/test_stanza_element.py
index c157e0a8..2a774d6c 100644
--- a/tests/test_stanza_element.py
+++ b/tests/test_stanza_element.py
@@ -607,7 +607,7 @@ class TestElementBase(SleekTest):
<foo xmlns="foo">
<foobar qux="a" />
</foo>
- """)
+ """, use_values=False)
self.failUnless(len(stanza) == 1,
"Incorrect stanza size with 1 substanza.")
@@ -617,7 +617,7 @@ class TestElementBase(SleekTest):
<foobar qux="a" />
<foobar qux="b" />
</foo>
- """)
+ """, use_values=False)
self.failUnless(len(stanza) == 2,
"Incorrect stanza size with 2 substanzas.")
@@ -627,7 +627,7 @@ class TestElementBase(SleekTest):
<foo xmlns="foo">
<foobar qux="b" />
</foo>
- """)
+ """, use_values=False)
# Test iterating over substanzas
stanza.append(substanza1)
diff --git a/tests/test_stanza_error.py b/tests/test_stanza_error.py
index f76ac62d..d5ed6f5f 100644
--- a/tests/test_stanza_error.py
+++ b/tests/test_stanza_error.py
@@ -30,11 +30,13 @@ class TestErrorStanzas(SleekTest):
self.failUnless(msg['error']['condition'] == 'item-not-found', "Error condition doesn't match.")
- del msg['error']['condition']
+ msg['error']['condition'] = 'resource-constraint'
self.check_message(msg, """
<message type="error">
- <error type="cancel" />
+ <error type="cancel">
+ <resource-constraint xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
+ </error>
</message>
""")
@@ -52,6 +54,6 @@ class TestErrorStanzas(SleekTest):
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Error!</text>
</error>
</message>
- """)
+ """, use_values=False)
suite = unittest.TestLoader().loadTestsFromTestCase(TestErrorStanzas)
diff --git a/tests/test_stanza_gmail.py b/tests/test_stanza_gmail.py
index 5c31a4e2..a5630e62 100644
--- a/tests/test_stanza_gmail.py
+++ b/tests/test_stanza_gmail.py
@@ -25,7 +25,7 @@ class TestGmail(SleekTest):
newer-than-tid="11134623426430234"
q="is:starred" />
</iq>
- """)
+ """, use_values=False)
def testMailBox(self):
"""Testing reading from Gmail mailbox result"""