def test_replace(self): """ Test if it replace a key from memcache server """ class MockMemcache(object): """ Mock of memcache """ def __init__(self): self.key = None self.value = None self.time = None self.min_compress_len = None @staticmethod def get_stats(): """ Mock of stats method """ return [("127.0.0.1:11211 (1)", {})] def replace(self, key, value, time, min_compress_len): """ Mock of replace method """ self.key = key self.value = value self.time = time self.min_compress_len = min_compress_len return True with patch.object( memcached, "_connect", MagicMock(return_value=MockMemcache()) ): self.assertTrue(memcached.replace("salt", "1111")) self.assertRaises( SaltInvocationError, memcached.replace, "salt", "1111", time="0.1" ) self.assertRaises( SaltInvocationError, memcached.replace, "salt", "1111", min_compress_len="0.1", )
def test_replace(self): ''' Test if it replace a key from memcache server ''' class MockMemcache(object): """ Mock of memcache """ def __init__(self): self.key = None self.value = None self.time = None self.min_compress_len = None @staticmethod def get_stats(): """ Mock of stats method """ return [('127.0.0.1:11211 (1)', {})] def replace(self, key, value, time, min_compress_len): """ Mock of replace method """ self.key = key self.value = value self.time = time self.min_compress_len = min_compress_len return True with patch.object(memcached, '_connect', MagicMock(return_value=MockMemcache())): self.assertTrue(memcached.replace('salt', '1111')) self.assertRaises(SaltInvocationError, memcached.replace, 'salt', '1111', time='0.1') self.assertRaises(SaltInvocationError, memcached.replace, 'salt', '1111', min_compress_len='0.1')