Mercurial > libervia-backend
comparison src/test/test_plugin_xep_0033.py @ 997:b3f383ab39da
test: configuration/use of new logging system
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 21 Apr 2014 20:04:52 +0200 |
parents | 301b342c697a |
children | c37a24922f27 |
comparison
equal
deleted
inserted
replaced
996:e99b6dfd567b | 997:b3f383ab39da |
---|---|
22 | 22 |
23 from constants import Const | 23 from constants import Const |
24 from sat.test import helpers | 24 from sat.test import helpers |
25 from sat.plugins import plugin_xep_0033 as plugin | 25 from sat.plugins import plugin_xep_0033 as plugin |
26 from sat.core.sat_main import AbortSendMessage, MessageSentAndStored | 26 from sat.core.sat_main import AbortSendMessage, MessageSentAndStored |
27 from sat.core.log import getLogger | |
27 from copy import deepcopy | 28 from copy import deepcopy |
28 from twisted.internet import defer | 29 from twisted.internet import defer |
29 from wokkel.generic import parseXml | 30 from wokkel.generic import parseXml |
30 from twisted.words.protocols.jabber.jid import JID | 31 from twisted.words.protocols.jabber.jid import JID |
31 import logging | 32 from logging import ERROR |
32 | 33 |
33 | 34 |
34 class XEP_0033Test(helpers.SatTestCase): | 35 class XEP_0033Test(helpers.SatTestCase): |
35 skip = "Must be fixed after disco changes" | 36 skip = "Must be fixed after disco changes" |
36 | 37 |
107 stored = [] | 108 stored = [] |
108 cache = set() | 109 cache = set() |
109 for to_s in [addresses[1], addresses[3], addresses[5]]: | 110 for to_s in [addresses[1], addresses[3], addresses[5]]: |
110 to_jid = JID(to_s) | 111 to_jid = JID(to_s) |
111 host = JID(to_jid.host) | 112 host = JID(to_jid.host) |
112 logger = logging.getLogger() | 113 logger = getLogger() |
113 level = logger.getEffectiveLevel() | 114 level = logger.getEffectiveLevel() |
114 logger.setLevel(logging.ERROR) # remove log.warning pollution | 115 logger.setLevel(ERROR) # remove log.warning pollution |
115 if self.host.memory.hasServerFeature(plugin.NS_ADDRESS, host, Const.PROFILE[0]): | 116 if self.host.memory.hasServerFeature(plugin.NS_ADDRESS, host, Const.PROFILE[0]): |
116 if host not in cache: | 117 if host not in cache: |
117 sent.append(host) | 118 sent.append(host) |
118 stored.append(host) | 119 stored.append(host) |
119 cache.add(host) | 120 cache.add(host) |
132 job. It should abort sending the message or add the extended | 133 job. It should abort sending the message or add the extended |
133 addressing information to the stanza. | 134 addressing information to the stanza. |
134 @param data: the data to be processed by self.plugin.sendMessageTrigger | 135 @param data: the data to be processed by self.plugin.sendMessageTrigger |
135 @param exception: AbortSendMessage or MessageSentAndStored | 136 @param exception: AbortSendMessage or MessageSentAndStored |
136 """ | 137 """ |
137 logger = logging.getLogger() | 138 logger = getLogger() |
138 level = logger.getEffectiveLevel() | 139 level = logger.getEffectiveLevel() |
139 logger.setLevel(logging.ERROR) # remove log.warning pollution | 140 logger.setLevel(ERROR) # remove log.warning pollution |
140 pre_treatments = defer.Deferred() | 141 pre_treatments = defer.Deferred() |
141 post_treatments = defer.Deferred() | 142 post_treatments = defer.Deferred() |
142 self.plugin.sendMessageTrigger(data, pre_treatments, post_treatments, Const.PROFILE[0]) | 143 self.plugin.sendMessageTrigger(data, pre_treatments, post_treatments, Const.PROFILE[0]) |
143 post_treatments.callback(data) | 144 post_treatments.callback(data) |
144 logger.setLevel(level) | 145 logger.setLevel(level) |