# HG changeset patch # User souliane # Date 1457714576 -3600 # Node ID 55440ee009050d158bade5ef89558a5dc5482567 # Parent 0681d69cbe0ab1d247d1cf111ffabf58d2c55562 test: update some tests diff -r 0681d69cbe0a -r 55440ee00905 src/test/helpers.py --- a/src/test/helpers.py Fri Mar 11 16:41:44 2016 +0100 +++ b/src/test/helpers.py Fri Mar 11 17:42:56 2016 +0100 @@ -190,12 +190,12 @@ entry = self.getSentMessage(profile_index) return entry.toXml() if entry else None - def findFeaturesSet(self, features, category=None, type_=None, jid_=None, profile_key=None): + def findFeaturesSet(self, features, identity=None, jid_=None, profile=C.PROF_KEY_NONE): """Call self.addFeature from your tests to change the return value. @return: a set of entities """ - client = self.getClient(profile_key) + client = self.getClient(profile) if jid_ is None: jid_ = JID(client.jid.host) try: @@ -301,7 +301,7 @@ # manipulating basic stuff, the others should be overwritten when needed self.host = host self.params = FakeParams(host, None) - self.config = self.parseMainConf() + self.config = tools_config.parseMainConf() self.reinit() def reinit(self): diff -r 0681d69cbe0a -r 55440ee00905 src/test/test_memory.py --- a/src/test/test_memory.py Fri Mar 11 16:41:44 2016 +0100 +++ b/src/test/test_memory.py Fri Mar 11 17:42:56 2016 +0100 @@ -131,7 +131,7 @@ """ if profile_key == '@NONE@': profile_key = '@DEFAULT@' - return self.host.memory.getParams(security_limit, app, profile_key) + return self.host.memory.params.getParams(security_limit, app, profile_key) def test_updateParams(self): self.host.memory.reinit() diff -r 0681d69cbe0a -r 55440ee00905 src/test/test_plugin_misc_groupblog.py --- a/src/test/test_plugin_misc_groupblog.py Fri Mar 11 16:41:44 2016 +0100 +++ b/src/test/test_plugin_misc_groupblog.py Fri Mar 11 17:42:56 2016 +0100 @@ -136,12 +136,13 @@ def setUp(self): self.host = helpers.FakeSAT() + self.host.plugins['XEP-0060'] = plugin_xep_0060.XEP_0060(self.host) + self.host.plugins['XEP-0163'] = plugin_xep_0163.XEP_0163(self.host) + reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error + self.host.plugins['TEXT-SYNTAXES'] = plugin_misc_text_syntaxes.TextSyntaxes(self.host) + self.host.plugins['XEP-0277'] = plugin_xep_0277.XEP_0277(self.host) self.plugin = plugin_misc_groupblog.GroupBlog(self.host) self.plugin._initialise = self._initialise - self.host.plugins['XEP-0060'] = plugin_xep_0060.XEP_0060(self.host) - self.host.plugins['XEP-0163'] = plugin_xep_0163.XEP_0163(self.host) - self.host.plugins['TEXT-SYNTAXES'] = plugin_misc_text_syntaxes.TextSyntaxes(self.host) - self.host.plugins['XEP-0277'] = plugin_xep_0277.XEP_0277(self.host) self.__initialised = False self._initialise(C.PROFILE[0]) diff -r 0681d69cbe0a -r 55440ee00905 src/test/test_plugin_misc_text_syntaxes.py --- a/src/test/test_plugin_misc_text_syntaxes.py Fri Mar 11 16:41:44 2016 +0100 +++ b/src/test/test_plugin_misc_text_syntaxes.py Fri Mar 11 17:42:56 2016 +0100 @@ -58,6 +58,7 @@ def setUp(self): self.host = helpers.FakeSAT() + reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error self.text_syntaxes = plugin_misc_text_syntaxes.TextSyntaxes(self.host) def test_xhtml_sanitise(self): diff -r 0681d69cbe0a -r 55440ee00905 src/test/test_plugin_xep_0277.py --- a/src/test/test_plugin_xep_0277.py Fri Mar 11 16:41:44 2016 +0100 +++ b/src/test/test_plugin_xep_0277.py Fri Mar 11 17:42:56 2016 +0100 @@ -21,6 +21,7 @@ from sat.test import helpers from sat.plugins import plugin_xep_0277 +from sat.plugins import plugin_xep_0060 from sat.plugins import plugin_misc_text_syntaxes from sat.tools.xml_tools import ElementParser @@ -69,7 +70,9 @@ def addPEPEvent(self, *args): pass + self.host.plugins["XEP-0060"] = plugin_xep_0060.XEP_0060(self.host) self.host.plugins["XEP-0163"] = XEP_0163(self.host) + reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error self.host.plugins["TEXT-SYNTAXES"] = plugin_misc_text_syntaxes.TextSyntaxes(self.host) self.plugin = plugin_xep_0277.XEP_0277(self.host) diff -r 0681d69cbe0a -r 55440ee00905 src/test/test_plugin_xep_0313.py --- a/src/test/test_plugin_xep_0313.py Fri Mar 11 16:41:44 2016 +0100 +++ b/src/test/test_plugin_xep_0313.py Fri Mar 11 17:42:56 2016 +0100 @@ -25,12 +25,13 @@ from sat.plugins.plugin_xep_0313 import XEP_0313 from twisted.words.protocols.jabber.jid import JID from twisted.words.xish import domish +from wokkel.data_form import Field from dateutil.tz import tzutc import datetime # TODO: change this when RSM and MAM are in wokkel from sat.tmp.wokkel.rsm import RSMRequest -from sat.tmp.wokkel.mam import buildForm +from sat.tmp.wokkel.mam import buildForm, MAMRequest NS_PUBSUB = 'http://jabber.org/protocol/pubsub' SERVICE = 'sat-pubsub.tazar.int' @@ -42,36 +43,37 @@ def setUp(self): self.host = helpers.FakeSAT() self.plugin = XEP_0313(self.host) - client = self.plugin.getHandler(C.PROFILE[0]) - client.makeConnection(self.host.getClient(C.PROFILE[0]).xmlstream) + self.client = self.host.getClient(C.PROFILE[0]) + mam_client = self.plugin.getHandler(C.PROFILE[0]) + mam_client.makeConnection(self.host.getClient(C.PROFILE[0]).xmlstream) def test_queryArchive(self): xml = """ - + """ % (("H_%d" % domish.Element._idCounter), SERVICE) - d = self.plugin.queryArchive(SERVICE_JID, profile_key=C.PROFILE[0]) + d = self.plugin.queryArchive(self.client, MAMRequest(), SERVICE_JID) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d def test_queryArchivePubsub(self): xml = """ - + """ % (("H_%d" % domish.Element._idCounter), SERVICE) - d = self.plugin.queryArchive(SERVICE_JID, node="fdp/submitted/capulet.lit/sonnets", profile_key=C.PROFILE[0]) + d = self.plugin.queryArchive(self.client, MAMRequest(node="fdp/submitted/capulet.lit/sonnets"), SERVICE_JID) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d def test_queryArchiveWith(self): xml = """ - + - urn:xmpp:mam:0 + urn:xmpp:mam:1 juliet@capulet.lit @@ -81,17 +83,17 @@ """ % (("H_%d" % domish.Element._idCounter), SERVICE) form = buildForm(with_jid=JID('juliet@capulet.lit')) - d = self.plugin.queryArchive(SERVICE_JID, form, profile_key=C.PROFILE[0]) + d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d def test_queryArchiveStartEnd(self): xml = """ - + - urn:xmpp:mam:0 + urn:xmpp:mam:1 2010-06-07T00:00:00Z @@ -106,17 +108,17 @@ start = datetime.datetime(2010, 6, 7, 0, 0, 0, tzinfo=tzutc()) end = datetime.datetime(2010, 7, 7, 13, 23, 54, tzinfo=tzutc()) form = buildForm(start=start, end=end) - d = self.plugin.queryArchive(SERVICE_JID, form, profile_key=C.PROFILE[0]) + d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d def test_queryArchiveStart(self): xml = """ - + - urn:xmpp:mam:0 + urn:xmpp:mam:1 2010-08-07T00:00:00Z @@ -127,17 +129,17 @@ """ % (("H_%d" % domish.Element._idCounter), SERVICE) start = datetime.datetime(2010, 8, 7, 0, 0, 0, tzinfo=tzutc()) form = buildForm(start=start) - d = self.plugin.queryArchive(SERVICE_JID, form, profile_key=C.PROFILE[0]) + d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d def test_queryArchiveRSM(self): xml = """ - + - urn:xmpp:mam:0 + urn:xmpp:mam:1 2010-08-07T00:00:00Z @@ -152,16 +154,16 @@ start = datetime.datetime(2010, 8, 7, 0, 0, 0, tzinfo=tzutc()) form = buildForm(start=start) rsm = RSMRequest(max_=10) - d = self.plugin.queryArchive(SERVICE_JID, form=form, rsm=rsm, profile_key=C.PROFILE[0]) + d = self.plugin.queryArchive(self.client, MAMRequest(form, rsm), SERVICE_JID) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d def test_queryArchiveRSMPaging(self): xml = """ - + - urn:xmpp:mam:0 + urn:xmpp:mam:1 2010-08-07T00:00:00Z @@ -174,27 +176,27 @@ start = datetime.datetime(2010, 8, 7, 0, 0, 0, tzinfo=tzutc()) form = buildForm(start=start) rsm = RSMRequest(max_=10, after=u'09af3-cc343-b409f') - d = self.plugin.queryArchive(SERVICE_JID, form=form, rsm=rsm, profile_key=C.PROFILE[0]) + d = self.plugin.queryArchive(self.client, MAMRequest(form, rsm), SERVICE_JID) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d def test_queryFields(self): xml = """ - + """ % (("H_%d" % domish.Element._idCounter), SERVICE) - d = self.plugin.queryFields(SERVICE_JID, C.PROFILE[0]) + d = self.plugin.queryFields(self.client, SERVICE_JID) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d def test_queryArchiveFields(self): xml = """ - + - urn:xmpp:mam:0 + urn:xmpp:mam:1 Where arth thou, my Juliet? @@ -206,34 +208,31 @@ """ % (("H_%d" % domish.Element._idCounter), SERVICE) - extra = [{'fieldType': 'text-single', - 'var': 'urn:example:xmpp:free-text-search', - 'value': 'Where arth thou, my Juliet?'}, - {'fieldType': 'text-single', - 'var': 'urn:example:xmpp:stanza-content', - 'value': '{http://jabber.org/protocol/mood}mood/lonely'}] - form = buildForm(extra=extra) - d = self.plugin.queryArchive(SERVICE_JID, form=form, profile_key=C.PROFILE[0]) + extra_fields = [Field('text-single', 'urn:example:xmpp:free-text-search', 'Where arth thou, my Juliet?'), + Field('text-single', 'urn:example:xmpp:stanza-content', '{http://jabber.org/protocol/mood}mood/lonely') + ] + form = buildForm(extra_fields=extra_fields) + d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d def test_queryPrefs(self): xml = """ - + """ % (("H_%d" % domish.Element._idCounter), SERVICE) - d = self.plugin.getPrefs(SERVICE_JID, profile_key=C.PROFILE[0]) + d = self.plugin.getPrefs(self.client, SERVICE_JID) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d def test_setPrefs(self): xml = """ - + romeo@montague.lit @@ -245,6 +244,6 @@ """ % (("H_%d" % domish.Element._idCounter), SERVICE) always = [JID('romeo@montague.lit')] never = [JID('montague@montague.lit')] - d = self.plugin.setPrefs(SERVICE_JID, always=always, never=never, profile_key=C.PROFILE[0]) + d = self.plugin.setPrefs(self.client, SERVICE_JID, always=always, never=never) d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True)) return d