changeset 997:b3f383ab39da

test: configuration/use of new logging system
author Goffi <goffi@goffi.org>
date Mon, 21 Apr 2014 20:04:52 +0200
parents e99b6dfd567b
children f5761534e0f3
files src/test/helpers.py src/test/test_memory.py src/test/test_plugin_misc_radiocol.py src/test/test_plugin_misc_room_game.py src/test/test_plugin_xep_0033.py
diffstat 5 files changed, 23 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/test/helpers.py	Mon Apr 21 19:45:10 2014 +0200
+++ b/src/test/helpers.py	Mon Apr 21 20:04:52 2014 +0200
@@ -30,6 +30,10 @@
 from collections import Counter
 import re
 
+## logging configuration for tests ##
+from sat.core import log
+log.satConfigure()
+
 
 def b2s(value):
     """Convert a bool to a unicode string used in bridge
--- a/src/test/test_memory.py	Mon Apr 21 19:45:10 2014 +0200
+++ b/src/test/test_memory.py	Mon Apr 21 20:04:52 2014 +0200
@@ -21,7 +21,8 @@
 from sat.test import helpers
 from twisted.trial import unittest
 import traceback
-import logging
+from sat.core.log import getLogger
+from logging import INFO
 from constants import Const
 from xml.dom import minidom
 
@@ -169,9 +170,9 @@
     def test_paramsRegisterApp(self):
 
         def register(*args):
-            logger = logging.getLogger()
+            logger = getLogger()
             level = logger.getEffectiveLevel()
-            logger.setLevel(logging.INFO)
+            logger.setLevel(INFO)
             self.host.memory.paramsRegisterApp(*args)
             logger.setLevel(level)
 
--- a/src/test/test_plugin_misc_radiocol.py	Mon Apr 21 19:45:10 2014 +0200
+++ b/src/test/test_plugin_misc_radiocol.py	Mon Apr 21 20:04:52 2014 +0200
@@ -21,6 +21,7 @@
 """ Tests for the plugin radiocol """
 
 from sat.core import exceptions
+from sat.core.log import getLogger
 from sat.test import helpers, helpers_plugins
 from sat.plugins import plugin_misc_radiocol as plugin
 from sat.plugins import plugin_misc_room_game as plugin_room_game
@@ -36,10 +37,10 @@
 from mutagen.oggvorbis import OggVorbis
 
 import uuid
-import logging
 import os
 import copy
 import shutil
+from logging import WARNING
 
 ROOM_JID_S = Const.MUC_STR[0]
 PROFILE = Const.PROFILE[0]
@@ -61,9 +62,9 @@
         self.plugin.testing = True
         self.plugin_0045 = self.host.plugins['XEP-0045'] = helpers_plugins.FakeXEP_0045(self.host)
         self.plugin_0249 = self.host.plugins['XEP-0249'] = helpers_plugins.FakeXEP_0249(self.host)
-        logger = logging.getLogger()
+        logger = getLogger()
         level = logger.getEffectiveLevel()
-        logger.setLevel(logging.WARNING)  # remove log.info pollution
+        logger.setLevel(WARNING)  # remove log.info pollution
         for profile in Const.PROFILE:
             self.host.getClient(profile)  # init self.host.profiles[profile]
         logger.setLevel(level)
--- a/src/test/test_plugin_misc_room_game.py	Mon Apr 21 19:45:10 2014 +0200
+++ b/src/test/test_plugin_misc_room_game.py	Mon Apr 21 20:04:52 2014 +0200
@@ -21,12 +21,14 @@
 """ Tests for the plugin room game (base class for MUC games) """
 
 from sat.core.i18n import _
+from sat.core.log import getLogger
 from constants import Const
 from sat.test import helpers, helpers_plugins
 from sat.plugins import plugin_misc_room_game as plugin
 from twisted.words.protocols.jabber.jid import JID
 from wokkel.muc import User
-import logging
+
+from logging import WARNING
 
 # Data used for test initialization
 NAMESERVICE = 'http://www.goffi.org/protocol/dummy'
@@ -58,9 +60,9 @@
         self.plugin._init_(self.host, PLUGIN_INFO, (NAMESERVICE, TAG), game_init, player_init)
         self.plugin_0045 = self.host.plugins['XEP-0045'] = helpers_plugins.FakeXEP_0045(self.host)
         self.plugin_0249 = self.host.plugins['XEP-0249'] = helpers_plugins.FakeXEP_0249(self.host)
-        logger = logging.getLogger()
+        logger = getLogger()
         level = logger.getEffectiveLevel()
-        logger.setLevel(logging.WARNING)  # remove log.info pollution
+        logger.setLevel(WARNING)  # remove log.info pollution
         for profile in Const.PROFILE:
             self.host.getClient(profile)  # init self.host.profiles[profile]
         logger.setLevel(level)
--- a/src/test/test_plugin_xep_0033.py	Mon Apr 21 19:45:10 2014 +0200
+++ b/src/test/test_plugin_xep_0033.py	Mon Apr 21 20:04:52 2014 +0200
@@ -24,11 +24,12 @@
 from sat.test import helpers
 from sat.plugins import plugin_xep_0033 as plugin
 from sat.core.sat_main import AbortSendMessage, MessageSentAndStored
+from sat.core.log import getLogger
 from copy import deepcopy
 from twisted.internet import defer
 from wokkel.generic import parseXml
 from twisted.words.protocols.jabber.jid import JID
-import logging
+from logging import ERROR
 
 
 class XEP_0033Test(helpers.SatTestCase):
@@ -109,9 +110,9 @@
             for to_s in [addresses[1], addresses[3], addresses[5]]:
                 to_jid = JID(to_s)
                 host = JID(to_jid.host)
-                logger = logging.getLogger()
+                logger = getLogger()
                 level = logger.getEffectiveLevel()
-                logger.setLevel(logging.ERROR)  # remove log.warning pollution
+                logger.setLevel(ERROR)  # remove log.warning pollution
                 if self.host.memory.hasServerFeature(plugin.NS_ADDRESS, host, Const.PROFILE[0]):
                     if host not in cache:
                         sent.append(host)
@@ -134,9 +135,9 @@
             @param data: the data to be processed by self.plugin.sendMessageTrigger
             @param exception: AbortSendMessage or MessageSentAndStored
             """
-            logger = logging.getLogger()
+            logger = getLogger()
             level = logger.getEffectiveLevel()
-            logger.setLevel(logging.ERROR)  # remove log.warning pollution
+            logger.setLevel(ERROR)  # remove log.warning pollution
             pre_treatments = defer.Deferred()
             post_treatments = defer.Deferred()
             self.plugin.sendMessageTrigger(data, pre_treatments, post_treatments, Const.PROFILE[0])