Condensed all of the stanzaPlugin functions into a single registerStanzaPlugin function.

Updated plugins and tests to use new function.
This commit is contained in:
Lance Stout
2010-07-19 13:58:53 -04:00
parent e6bec8681e
commit d5e42ac0e7
23 changed files with 98 additions and 106 deletions

View File

@@ -17,6 +17,8 @@ from sleekxmpp import ClientXMPP
from sleekxmpp import Message, Iq
from sleekxmpp.stanza.presence import Presence
from sleekxmpp.xmlstream.matcher.stanzapath import StanzaPath
from sleekxmpp.xmlstream.stanzabase import registerStanzaPlugin
class TestSocket(object):
@@ -88,14 +90,6 @@ class SleekTest(unittest.TestCase):
methods for comparing message, iq, and presence stanzas.
"""
def stanzaPlugin(self, stanza, plugin):
"""
Associate a stanza object as a plugin for another stanza.
"""
tag = "{%s}%s" % (plugin.namespace, plugin.name)
stanza.plugin_attrib_map[plugin.plugin_attrib] = plugin
stanza.plugin_tag_map[tag] = plugin
# ------------------------------------------------------------------
# Shortcut methods for creating stanza objects

View File

@@ -5,7 +5,7 @@ import sleekxmpp.plugins.xep_0033 as xep_0033
class TestAddresses(SleekTest):
def setUp(self):
self.stanzaPlugin(Message, xep_0033.Addresses)
registerStanzaPlugin(Message, xep_0033.Addresses)
def testAddAddress(self):
"""Testing adding extended stanza address."""

View File

@@ -4,11 +4,11 @@ import sleekxmpp.plugins.xep_0085 as xep_0085
class TestChatStates(SleekTest):
def setUp(self):
self.stanzaPlugin(Message, xep_0085.Active)
self.stanzaPlugin(Message, xep_0085.Composing)
self.stanzaPlugin(Message, xep_0085.Gone)
self.stanzaPlugin(Message, xep_0085.Inactive)
self.stanzaPlugin(Message, xep_0085.Paused)
registerStanzaPlugin(Message, xep_0085.Active)
registerStanzaPlugin(Message, xep_0085.Composing)
registerStanzaPlugin(Message, xep_0085.Gone)
registerStanzaPlugin(Message, xep_0085.Inactive)
registerStanzaPlugin(Message, xep_0085.Paused)
def testCreateChatState(self):
"""Testing creating chat states."""

View File

@@ -5,8 +5,8 @@ import sleekxmpp.plugins.xep_0030 as xep_0030
class TestDisco(SleekTest):
def setUp(self):
self.stanzaPlugin(Iq, xep_0030.DiscoInfo)
self.stanzaPlugin(Iq, xep_0030.DiscoItems)
registerStanzaPlugin(Iq, xep_0030.DiscoInfo)
registerStanzaPlugin(Iq, xep_0030.DiscoItems)
def testCreateInfoQueryNoNode(self):
"""Testing disco#info query with no node."""

View File

@@ -5,9 +5,9 @@ import sleekxmpp.plugins.alt_0004 as xep_0004
class TestDataForms(SleekTest):
def setUp(self):
self.stanzaPlugin(Message, xep_0004.Form)
self.stanzaPlugin(xep_0004.Form, xep_0004.FormField)
self.stanzaPlugin(xep_0004.FormField, xep_0004.FieldOption)
registerStanzaPlugin(Message, xep_0004.Form)
registerStanzaPlugin(xep_0004.Form, xep_0004.FormField)
registerStanzaPlugin(xep_0004.FormField, xep_0004.FieldOption)
def testMultipleInstructions(self):
"""Testing using multiple instructions elements in a data form."""

View File

@@ -5,9 +5,9 @@ import sleekxmpp.plugins.gmail_notify as gmail
class TestGmail(SleekTest):
def setUp(self):
self.stanzaPlugin(Iq, gmail.GmailQuery)
self.stanzaPlugin(Iq, gmail.MailBox)
self.stanzaPlugin(Iq, gmail.NewMail)
registerStanzaPlugin(Iq, gmail.GmailQuery)
registerStanzaPlugin(Iq, gmail.MailBox)
registerStanzaPlugin(Iq, gmail.NewMail)
def testCreateQuery(self):
"""Testing querying Gmail for emails."""

View File

@@ -5,9 +5,9 @@ class testmessagestanzas(unittest.TestCase):
def setUp(self):
import sleekxmpp.stanza.message as m
from sleekxmpp.basexmpp import stanzaPlugin
from sleekxmpp.basexmpp import registerStanzaPlugin
from sleekxmpp.stanza.htmlim import HTMLIM
stanzaPlugin(m.Message, HTMLIM)
registerStanzaPlugin(m.Message, HTMLIM)
self.m = m
def testGroupchatReplyRegression(self):