Exemple #1
0
    def test_delete(self):
        '''
        Test if it delete a key from memcache server
        '''
        class MockMemcache(object):
            """
            Mock of memcache
            """
            def __init__(self):
                self.key = None
                self.time = None

            @staticmethod
            def get_stats():
                """
                Mock of stats method
                """
                return [('127.0.0.1:11211 (1)', {})]

            def delete(self, key, time):
                """
                Mock of delete method
                """
                self.key = key
                self.time = time
                return True

        with patch.object(memcached, '_connect',
                          MagicMock(return_value=MockMemcache())):
            self.assertTrue(memcached.delete('salt'))

            self.assertRaises(SaltInvocationError, memcached.delete,
                              'salt', '1111', time='0.1')
Exemple #2
0
    def test_delete(self):
        '''
        Test if it delete a key from memcache server
        '''
        class MockMemcache(object):
            """
            Mock of memcache
            """
            def __init__(self):
                self.key = None
                self.time = None

            @staticmethod
            def get_stats():
                """
                Mock of stats method
                """
                return [('127.0.0.1:11211 (1)', {})]

            def delete(self, key, time):
                """
                Mock of delete method
                """
                self.key = key
                self.time = time
                return True

        with patch.object(memcached, '_connect',
                          MagicMock(return_value=MockMemcache())):
            self.assertTrue(memcached.delete('salt'))

            self.assertRaises(SaltInvocationError, memcached.delete,
                              'salt', '1111', time='0.1')
Exemple #3
0
    def test_delete(self):
        """
        Test if it delete a key from memcache server
        """

        class MockMemcache(object):
            """
            Mock of memcache
            """

            def __init__(self):
                self.key = None
                self.time = None

            @staticmethod
            def get_stats():
                """
                Mock of stats method
                """
                return [("127.0.0.1:11211 (1)", {})]

            def delete(self, key, time):
                """
                Mock of delete method
                """
                self.key = key
                self.time = time
                return True

        with patch.object(
            memcached, "_connect", MagicMock(return_value=MockMemcache())
        ):
            self.assertTrue(memcached.delete("salt"))

            self.assertRaises(
                SaltInvocationError, memcached.delete, "salt", "1111", time="0.1"
            )