diff src/test/test_plugin_xep_0033.py @ 1909:0681d69cbe0a

test: add helpers methods muteLogging and unmuteLogging
author souliane <souliane@mailoo.org>
date Fri, 11 Mar 2016 16:41:44 +0100
parents d17772b0fe22
children 2daf7b4c6756
line wrap: on
line diff
--- a/src/test/test_plugin_xep_0033.py	Fri Mar 11 16:38:23 2016 +0100
+++ b/src/test/test_plugin_xep_0033.py	Fri Mar 11 16:41:44 2016 +0100
@@ -24,7 +24,6 @@
 from sat.test import helpers
 from sat.plugins import plugin_xep_0033 as plugin
 from sat.core.exceptions import CancelError
-from sat.core.log import getLogger
 from twisted.internet import defer
 from wokkel.generic import parseXml
 from twisted.words.protocols.jabber.jid import JID
@@ -108,7 +107,7 @@
         stored = []
         d_list = []
 
-        def cb(entities, to_jid, logger, level):
+        def cb(entities, to_jid):
             if host in entities:
                 if host not in sent:  # send the message to the entity offering the feature
                     sent.append(host)
@@ -117,16 +116,14 @@
             else:  # feature not supported, use normal behavior
                 sent.append(to_jid)
                 stored.append(to_jid)
-            logger.setLevel(level)
+            helpers.unmuteLogging()
 
         for to_s in (JID_STR_X_TO, JID_STR_X_CC, JID_STR_X_BCC):
             to_jid = JID(to_s)
             host = JID(to_jid.host)
-            logger = getLogger()
-            level = logger.getEffectiveLevel()
-            logger.setLevel(ERROR)  # remove log.warning pollution
-            d = self.host.findFeaturesSet([plugin.NS_ADDRESS], jid_=host, profile_key=PROFILE)
-            d.addCallback(cb, to_jid, logger, level)
+            helpers.muteLogging()
+            d = self.host.findFeaturesSet([plugin.NS_ADDRESS], jid_=host, profile=PROFILE)
+            d.addCallback(cb, to_jid)
             d_list.append(d)
 
         def cb_list(dummy):
@@ -144,14 +141,12 @@
         addressing information to the stanza.
         @param data: the data to be processed by self.plugin.sendMessageTrigger
         """
-        logger = getLogger()
-        level = logger.getEffectiveLevel()
-        logger.setLevel(ERROR)  # remove log.warning pollution
         pre_treatments = defer.Deferred()
         post_treatments = defer.Deferred()
+        helpers.muteLogging()
         self.plugin.sendMessageTrigger(data, pre_treatments, post_treatments, PROFILE)
         post_treatments.callback(data)
-        logger.setLevel(level)
+        helpers.unmuteLogging()
         post_treatments.addCallbacks(self._assertAddresses, lambda failure: failure.trap(CancelError))
         return post_treatments