diff src/test/test_plugin_xep_0033.py @ 1955:633b5c21aefd

backend, frontend: messages refactoring (huge commit, not finished): /!\ database schema has been modified, do a backup before updating message have been refactored, here are the main changes: - languages are now handled - all messages have an uid (internal to SàT) - message updating is anticipated - subject is now first class - new naming scheme is used newMessage => messageNew, getHistory => historyGet, sendMessage => messageSend - minimal compatibility refactoring in quick_frontend/Primitivus, better refactoring should follow - threads handling - delayed messages are saved into history - info messages may also be saved in history (e.g. to keep track of people joining/leaving a room) - duplicate messages should be avoided - historyGet return messages in right order, no need to sort again - plugins have been updated to follow new features, some of them need to be reworked (e.g. OTR) - XEP-0203 (Delayed Delivery) is now fully handled in core, the plugin just handle disco and creation of a delay element - /!\ jp and Libervia are currently broken, as some features of Primitivus It has been put in one huge commit to avoid breaking messaging between changes. This is the main part of message refactoring, other commits will follow to take profit of the new features/behaviour.
author Goffi <goffi@goffi.org>
date Tue, 24 May 2016 22:11:04 +0200
parents 2daf7b4c6756
children 8b37a62336c3
line wrap: on
line diff
--- a/src/test/test_plugin_xep_0033.py	Mon Apr 18 18:35:19 2016 +0200
+++ b/src/test/test_plugin_xep_0033.py	Tue May 24 22:11:04 2016 +0200
@@ -27,7 +27,6 @@
 from twisted.internet import defer
 from wokkel.generic import parseXml
 from twisted.words.protocols.jabber.jid import JID
-from logging import ERROR
 
 PROFILE_INDEX = 0
 PROFILE = Const.PROFILE[PROFILE_INDEX]
@@ -60,7 +59,7 @@
         """ % (JID_STR_FROM, JID_STR_TO, JID_STR_X_TO, JID_STR_X_CC, JID_STR_X_BCC)
         stanza = parseXml(xml.encode("utf-8"))
         treatments = defer.Deferred()
-        self.plugin.messageReceivedTrigger(stanza, treatments, PROFILE)
+        self.plugin.messageReceivedTrigger(self.host.getClient(PROFILE), stanza, treatments)
         data = {'extra': {}}
 
         def cb(data):
@@ -87,7 +86,7 @@
         return mess_data
 
     def _assertAddresses(self, mess_data):
-        """The mess_data that we got here has been modified by self.plugin.sendMessageTrigger,
+        """The mess_data that we got here has been modified by self.plugin.messageSendTrigger,
         check that the addresses element has been added to the stanza."""
         expected = self._get_mess_data()['xml']
         addresses_extra = """
@@ -135,28 +134,28 @@
         return defer.DeferredList(d_list).addCallback(cb_list)
 
     def _trigger(self, data):
-        """Execute self.plugin.sendMessageTrigger with a different logging
+        """Execute self.plugin.messageSendTrigger with a different logging
         level to not pollute the output, then check that the plugin did its
         job. It should abort sending the message or add the extended
         addressing information to the stanza.
-        @param data: the data to be processed by self.plugin.sendMessageTrigger
+        @param data: the data to be processed by self.plugin.messageSendTrigger
         """
         pre_treatments = defer.Deferred()
         post_treatments = defer.Deferred()
         helpers.muteLogging()
-        self.plugin.sendMessageTrigger(data, pre_treatments, post_treatments, PROFILE)
+        self.plugin.messageSendTrigger(self.host.getClient[PROFILE], data, pre_treatments, post_treatments)
         post_treatments.callback(data)
         helpers.unmuteLogging()
         post_treatments.addCallbacks(self._assertAddresses, lambda failure: failure.trap(CancelError))
         return post_treatments
 
-    def test_sendMessageTriggerFeatureNotSupported(self):
+    def test_messageSendTriggerFeatureNotSupported(self):
         # feature is not supported, abort the message
         self.host.memory.reinit()
         data = self._get_mess_data()
         return self._trigger(data)
 
-    def test_sendMessageTriggerFeatureSupported(self):
+    def test_messageSendTriggerFeatureSupported(self):
         # feature is supported by the main target server
         self.host.reinit()
         self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE)
@@ -164,7 +163,7 @@
         d = self._trigger(data)
         return d.addCallback(lambda dummy: self._checkSentAndStored())
 
-    def test_sendMessageTriggerFeatureFullySupported(self):
+    def test_messageSendTriggerFeatureFullySupported(self):
         # feature is supported by all target servers
         self.host.reinit()
         self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE)
@@ -174,7 +173,7 @@
         d = self._trigger(data)
         return d.addCallback(lambda dummy: self._checkSentAndStored())
 
-    def test_sendMessageTriggerFixWrongEntity(self):
+    def test_messageSendTriggerFixWrongEntity(self):
         # check that a wrong recipient entity is fixed by the backend
         self.host.reinit()
         self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE)