From 218c7318e040cd8acb90dfc445b7388a37756d8b Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Fri, 8 Jan 2010 07:01:19 +0000 Subject: * added tests --- tests/pubsub_stanzas.py | 26 -------------------------- tests/test_messagestanzas.py | 19 +++++++++++++++++++ tests/test_pubsubstanzas.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 26 deletions(-) delete mode 100644 tests/pubsub_stanzas.py create mode 100644 tests/test_messagestanzas.py create mode 100644 tests/test_pubsubstanzas.py (limited to 'tests') diff --git a/tests/pubsub_stanzas.py b/tests/pubsub_stanzas.py deleted file mode 100644 index d768a3df..00000000 --- a/tests/pubsub_stanzas.py +++ /dev/null @@ -1,26 +0,0 @@ -from sleekxmpp.plugins.stanza_pubsub import * - -def testAffiliations(): - iq = Iq() - aff1 = Affiliation() - aff1['node'] = 'testnode' - aff1['affiliation'] = 'owner' - aff2 = Affiliation() - aff2['node'] = 'testnode2' - aff2['affiliation'] = 'publisher' - iq['pubsub']['affiliations'].append(aff1) - iq['pubsub']['affiliations'].append(aff2) - print(iq) - iq2 = Iq(None, ET.fromstring("""""")) - iq3 = Iq() - values = iq2.getValues() - print(values) - iq3.setValues(values) - print("-"*8) - print(iq3.keys()) - - print(iq3) - print(str(iq) == str(iq2) == str(iq3)) - - -testAffiliations() diff --git a/tests/test_messagestanzas.py b/tests/test_messagestanzas.py new file mode 100644 index 00000000..ec44803f --- /dev/null +++ b/tests/test_messagestanzas.py @@ -0,0 +1,19 @@ +import unittest + +class testmessagestanzas(unittest.TestCase): + + def setUp(self): + import sleekxmpp.stanza.message as m + self.m = m + + def testGroupchatReplyRegression(self): + "Regression groupchat reply should be to barejid" + msg = self.m.Message() + msg['to'] = 'me@myserver.tld' + msg['from'] = 'room@someservice.someserver.tld/somenick' + msg['type'] = 'groupchat' + msg['body'] = "this is a message" + msg.reply() + self.failUnless(str(msg['to']) == 'room@someservice.someserver.tld') + +suite = unittest.TestLoader().loadTestsFromTestCase(testmessagestanzas) diff --git a/tests/test_pubsubstanzas.py b/tests/test_pubsubstanzas.py new file mode 100644 index 00000000..37deeca1 --- /dev/null +++ b/tests/test_pubsubstanzas.py @@ -0,0 +1,28 @@ +import unittest + +class testpubsubstanzas(unittest.TestCase): + + def setUp(self): + import sleekxmpp.plugins.stanza_pubsub as ps + self.ps = ps + + def testAffiliations(self): + "Testing iq/pubsub/affiliations/affiliation stanzas" + iq = self.ps.Iq() + aff1 = self.ps.Affiliation() + aff1['node'] = 'testnode' + aff1['affiliation'] = 'owner' + aff2 = self.ps.Affiliation() + aff2['node'] = 'testnode2' + aff2['affiliation'] = 'publisher' + iq['pubsub']['affiliations'].append(aff1) + iq['pubsub']['affiliations'].append(aff2) + xmlstring = """""" + iq2 = self.ps.Iq(None, self.ps.ET.fromstring(xmlstring)) + iq3 = self.ps.Iq() + values = iq2.getValues() + iq3.setValues(values) + self.failUnless(xmlstring == str(iq) == str(iq2) == str(iq3)) + + +suite = unittest.TestLoader().loadTestsFromTestCase(testpubsubstanzas) -- cgit v1.2.3