Test: caps cache: use mock from unittest

This commit is contained in:
André Apitzsch 2018-11-10 18:23:40 +01:00 committed by Philipp Hörist
parent 49758ab30e
commit 522eec007d
1 changed files with 7 additions and 6 deletions

View File

@ -6,13 +6,11 @@ import unittest
import lib
lib.setup_env()
from unittest.mock import MagicMock
from unittest.mock import MagicMock, Mock
from nbxmpp import NS_MUC, NS_PING, NS_XHTML_IM, Iq
from gajim.common import caps_cache as caps
from gajim.common.modules.discovery import Discovery
from mock import Mock
COMPLEX_EXAMPLE = '''
<iq from='benvolio@capulet.lit/230193' id='disco1' to='juliet@capulet.lit/chamber' type='result'>
<query xmlns='http://jabber.org/protocol/disco#info' node='http://psi-im.org#q07IKJEyjvHSyhy//CH0CxmKi8w='>
@ -64,7 +62,8 @@ class CommonCapsTest(unittest.TestCase):
db_caps_cache = [
(self.caps_method, self.caps_hash, self.identities, self.features),
('old', self.node + '#' + self.caps_hash, self.identities, self.features)]
self.logger = Mock(returnValues={"iter_caps_data":db_caps_cache})
self.logger = Mock()
self.logger.iter_caps_data = Mock(return_value=db_caps_cache)
self.cc = caps.CapsCache(self.logger)
caps.capscache = self.cc
@ -95,8 +94,10 @@ class TestCapsCache(CommonCapsTest):
item = self.cc[self.client_caps]
item.set_and_store(self.identities, self.features)
self.logger.mockCheckCall(0, "add_caps_entry", self.caps_method,
self.caps_hash, self.identities, self.features)
self.logger.add_caps_entry.assert_called_once_with(self.caps_method,
self.caps_hash,
self.identities,
self.features)
def test_initialize_from_db(self):
''' Read cashed dummy data from db '''