def test_set(self): """ Test if it set a key on the memcached 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 set(self, key, value, time, min_compress_len): """ Mock of set 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.set_("salt", "1111")) self.assertRaises( SaltInvocationError, memcached.set_, "salt", "1111", time="0.1" ) self.assertRaises( SaltInvocationError, memcached.set_, "salt", "1111", min_compress_len="0.1", )
def test_set(self): ''' Test if it set a key on the memcached 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 set(self, key, value, time, min_compress_len): """ Mock of set 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.set_('salt', '1111')) self.assertRaises(SaltInvocationError, memcached.set_, 'salt', '1111', time='0.1') self.assertRaises(SaltInvocationError, memcached.set_, 'salt', '1111', min_compress_len='0.1')