diff --git a/src/test/helpers.py b/src/test/helpers.py
index c09e4e47..c5383af8 100644
--- a/src/test/helpers.py
+++ b/src/test/helpers.py
@@ -190,12 +190,12 @@ class FakeSAT(object):
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 @@ class FakeMemory(Memory):
# 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 --git a/src/test/test_memory.py b/src/test/test_memory.py
index 61082203..251c05a9 100644
--- a/src/test/test_memory.py
+++ b/src/test/test_memory.py
@@ -131,7 +131,7 @@ class MemoryTest(unittest.TestCase):
"""
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 --git a/src/test/test_plugin_misc_groupblog.py b/src/test/test_plugin_misc_groupblog.py
index 1c5d2994..d2dddb35 100644
--- a/src/test/test_plugin_misc_groupblog.py
+++ b/src/test/test_plugin_misc_groupblog.py
@@ -136,12 +136,13 @@ class XEP_groupblogTest(helpers.SatTestCase):
def setUp(self):
self.host = helpers.FakeSAT()
- 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)
+ 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.__initialised = False
self._initialise(C.PROFILE[0])
diff --git a/src/test/test_plugin_misc_text_syntaxes.py b/src/test/test_plugin_misc_text_syntaxes.py
index 6f5401eb..71d93517 100644
--- a/src/test/test_plugin_misc_text_syntaxes.py
+++ b/src/test/test_plugin_misc_text_syntaxes.py
@@ -58,6 +58,7 @@ class SanitisationTest(helpers.SatTestCase):
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 --git a/src/test/test_plugin_xep_0277.py b/src/test/test_plugin_xep_0277.py
index 592a3e9c..65af38b7 100644
--- a/src/test/test_plugin_xep_0277.py
+++ b/src/test/test_plugin_xep_0277.py
@@ -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 @@ class XEP_0277Test(helpers.SatTestCase):
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 --git a/src/test/test_plugin_xep_0313.py b/src/test/test_plugin_xep_0313.py
index 5b6a2792..ab3d86c8 100644
--- a/src/test/test_plugin_xep_0313.py
+++ b/src/test/test_plugin_xep_0313.py
@@ -25,12 +25,13 @@ from sat.test import helpers
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 @@ class XEP_0313Test(helpers.SatTestCase):
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 @@ class XEP_0313Test(helpers.SatTestCase):
""" % (("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 @@ class XEP_0313Test(helpers.SatTestCase):
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 @@ class XEP_0313Test(helpers.SatTestCase):
""" % (("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 @@ class XEP_0313Test(helpers.SatTestCase):
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 @@ class XEP_0313Test(helpers.SatTestCase):
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 @@ class XEP_0313Test(helpers.SatTestCase):
""" % (("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 @@ class XEP_0313Test(helpers.SatTestCase):
""" % (("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