Ejemplo n.º 1
0
    def testVersion(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        v = c.version()
        l = v.split('.')

        self.assertEquals(3, len(l))
Ejemplo n.º 2
0
    def testStats(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        d = c.stats()

        self.assertTrue(d.has_key("uptime"))
        self.assertTrue(d.has_key("bytes"))
Ejemplo n.º 3
0
    def testStats(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        d = c.stats()

        self.assertTrue(d.has_key("uptime"))
        self.assertTrue(d.has_key("bytes"))
Ejemplo n.º 4
0
    def testVersion(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        v = c.version()
        l = v.split(".")

        self.assertEquals(3, len(l))
Ejemplo n.º 5
0
 def testCas(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "a")
     value, flags, cas = c.gets("key1")
     self.assertEquals("STORED", c.cas("key1", "b", cas))
     c.set("key1", "a")
     self.assertEquals("EXISTS", c.cas("key1", "b", cas))
Ejemplo n.º 6
0
 def testOversizedKey(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     data = "A" * (1000 * 1000 * 2)
     try:
         r = c.set("test", data)
         assert False
     except (RuntimeError):
         pass
Ejemplo n.º 7
0
 def testOversizedKey(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     data = "A" * (1000 * 1000 * 2)
     try:
         r = c.set("test", data)
         assert False
     except (RuntimeError):
         pass
Ejemplo n.º 8
0
    def testConnectFails(self):
        c = Client("130.244.1.1:31337")
        try:
            c.connect()
            assert False
        except:
            pass

        c.disconnect()
        pass
Ejemplo n.º 9
0
    def testConnectDNSFails(self):
        c = Client("flensost:12111")
        try:
            c.connect()
            assert False
        except:
            pass

        c.disconnect()
        pass
Ejemplo n.º 10
0
 def testDel(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "a")
     c.delete("key1")
     self.assertEquals(None, c.get("key1"))
     pass
Ejemplo n.º 11
0
 def testGets(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key", "value")
     self.assertEquals("value", c.gets("key")[0])
     self.assertEquals(None, c.gets("key23123"))
     r = c.gets("key")
     self.assertEquals(3, len(r))
     pass
Ejemplo n.º 12
0
 def testDel(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "a")
     c.delete("key1")
     self.assertEquals(None, c.get("key1"))
     pass
Ejemplo n.º 13
0
 def testPrepend(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "a")
     self.assertEquals("STORED", c.prepend("key1", "b"))
     self.assertEquals("ba", c.get("key1")[0])
     pass
Ejemplo n.º 14
0
 def testGets(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key", "value")
     self.assertEquals("value", c.gets("key")[0])
     self.assertEquals(None, c.gets("key23123"))
     r = c.gets("key")
     self.assertEquals(3, len(r))
     pass
Ejemplo n.º 15
0
    def testConnectTwice(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        c.disconnect()
        self.assertEquals(False, c.is_connected())

        try:
            c.connect()
            assert False
        except (RuntimeError):
            pass

        pass
Ejemplo n.º 16
0
 def testPrepend(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "a")
     self.assertEquals("STORED", c.prepend("key1", "b"))
     self.assertEquals("ba", c.get("key1")[0])
     pass
Ejemplo n.º 17
0
    def testGet_multi(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        c.set("key1", "value1")
        c.set("key2", "value2")
        c.set("key3", "value3")
        r = c.get_multi(["key1", "key2", "key3", "key4"])

        self.assertEquals(("value1", 0), r["key1"])
        self.assertEquals(("value2", 0), r["key2"])
        self.assertEquals(("value3", 0), r["key3"])
        self.assertEquals(None, r.get("key4"))

        pass
Ejemplo n.º 18
0
    def testReplace(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        c.set("key1", "value1")
        self.assertEquals("STORED", c.replace("key1", "value"))
        pass

        pass
Ejemplo n.º 19
0
 def testConnectCloseQuery(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.disconnect()
     try:
         r = c.set("jonas", "kaka", 0, False)
         assert False
     except:
         pass
Ejemplo n.º 20
0
    def testConnectTwice(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        c.disconnect()
        self.assertEquals(False, c.is_connected())

        try:
            c.connect()
            assert False
        except (RuntimeError):
            pass

        pass
Ejemplo n.º 21
0
    def testBigDataFail(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        data = "31337" * 10000

        for x in xrange(0, 10):
            v = c.get("kaka" + str(x))
            c.set(
                "fsdafbdsakjfjdkfjadklsafdsafdsaffdsafdasfdsafdasfsdafdsafdsafasdas"
                + str(x), data, 604830, 17, True)
Ejemplo n.º 22
0
    def testGet_multi(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        c.set("key1", "value1")
        c.set("key2", "value2")
        c.set("key3", "value3")
        r = c.get_multi(["key1", "key2", "key3", "key4"])

        self.assertEquals(("value1", 0), r["key1"])
        self.assertEquals(("value2", 0), r["key2"])
        self.assertEquals(("value3", 0), r["key3"])
        self.assertEquals(None, r.get("key4"))

        pass
Ejemplo n.º 23
0
    def testBigDataFail(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        data = "31337" * 10000

        for x in xrange(0, 10):
            v = c.get("kaka" + str(x))
            c.set("fsdafbdsakjfjdkfjadklsafdsafdsaffdsafdasfdsafdasfsdafdsafdsafasdas" + str(x), data, 604830, 17, True)
Ejemplo n.º 24
0
    def testReplace(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()
        c.set("key1", "value1")
        self.assertEquals("STORED", c.replace("key1", "value"))
        pass

        pass
Ejemplo n.º 25
0
 def testConnectCloseQuery(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.disconnect()
     try:
         r = c.set("jonas", "kaka", 0, False)
         assert False
     except:
         pass
Ejemplo n.º 26
0
    def testConnectFails(self):
        c = Client("130.244.1.1:31337")
        try:
            c.connect()
            assert False
        except:
            pass

        c.disconnect()
        pass
Ejemplo n.º 27
0
    def testConnectDNSFails(self):
        c = Client("flensost:12111")
        try:
            c.connect()
            assert False
        except:
            pass

        c.disconnect()
        pass
Ejemplo n.º 28
0
    def testRandomData(self):
        def random_bytes(size):
            return "".join(chr(random.randrange(0, 256)) for i in xrange(size))

        def random_str(size):
            return "".join(chr(random.randrange(33, 64)) for i in xrange(size))

        c = Client(MEMCACHED_ADDRESS)
        c.connect()

        count = 0

        for x in xrange(0, 10):
            key = random_str(random.randrange(1, 33))
            value = random_bytes(random.randrange(1, 5000))
            c.set(key, value, 0, 0, True)
            v2 = c.get(key)[0]

            count += 1

            if len(value) != len(v2):
                print "%d %d != %d" % (count, len(value), len(v2))
Ejemplo n.º 29
0
    def testRandomData(self):
        def random_bytes(size):
            return "".join(chr(random.randrange(0, 256)) for i in xrange(size))

        def random_str(size):
            return "".join(chr(random.randrange(33, 64)) for i in xrange(size))

        c = Client(MEMCACHED_ADDRESS)
        c.connect()

        count = 0

        for x in xrange(0, 10):
            key = random_str(random.randrange(1, 33))
            value = random_bytes(random.randrange(1, 5000))
            c.set(key, value, 0, 0, True)
            v2 = c.get(key)[0]

            count += 1

            if len(value) != len(v2):
                print "%d %d != %d" % (count, len(value), len(v2))
Ejemplo n.º 30
0
 def testIncr(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "0")
     c.incr("key1", 313370)
     self.assertEquals("313370", c.get("key1")[0])
Ejemplo n.º 31
0
 def testIncr(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "0")
     c.incr("key1", 313370)
     self.assertEquals("313370", c.get("key1")[0])
Ejemplo n.º 32
0
 def testDecr(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "31337")
     c.decr("key1", 31337)
     self.assertEquals(0, long(c.get("key1")[0]))
Ejemplo n.º 33
0
 def testClose(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.close()
     self.assertEquals(False, c.is_connected())
     pass
Ejemplo n.º 34
0
 def testConnectDNSOK(self):
     c = Client("localhost:11211")
     c.connect()
     c.disconnect()
     pass
Ejemplo n.º 35
0
 def testAdd(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "value1")
     self.assertEquals("NOT_STORED", c.add("key1", "value"))
     pass
Ejemplo n.º 36
0
 def testSet(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key", "my new value")
     self.assertEquals("my new value", c.get("key")[0])
     pass
Ejemplo n.º 37
0
 def testClose(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.close()
     self.assertEquals(False, c.is_connected())
     pass
Ejemplo n.º 38
0
 def testConnect(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     self.assertEquals(True, c.is_connected())
     pass
Ejemplo n.º 39
0
 def testDecr(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "31337")
     c.decr("key1", 31337)
     self.assertEquals(0, long(c.get("key1")[0]))
Ejemplo n.º 40
0
 def testCas(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "a")
     value, flags, cas = c.gets("key1")
     self.assertEquals("STORED", c.cas("key1", "b", cas))
     c.set("key1", "a")
     self.assertEquals("EXISTS", c.cas("key1", "b", cas))
Ejemplo n.º 41
0
 def testConnectDNSOK(self):
     c = Client("localhost:11211")
     c.connect()
     c.disconnect()
     pass
Ejemplo n.º 42
0
 def testSet(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key", "my new value")
     self.assertEquals("my new value", c.get("key")[0])
     pass
Ejemplo n.º 43
0
 def testAdd(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "value1")
     self.assertEquals("NOT_STORED", c.add("key1", "value"))
     pass
Ejemplo n.º 44
0
 def testIncrDecrString(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("test", "hej")
     self.assertRaises(Exception, c.incr, "test", 1)
     self.assertRaises(Exception, c.decr, "test", 5)
Ejemplo n.º 45
0
 def testIncrDecrString(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("test", "hej")
     self.assertRaises(Exception, c.incr, "test", 1)
     self.assertRaises(Exception, c.decr, "test", 5)
Ejemplo n.º 46
0
 def testSetExpiration(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("test", "1", 60, 2)
Ejemplo n.º 47
0
 def testSegfault(self):
     try:
         c = Client()
         assert False
     except (TypeError):
         pass
Ejemplo n.º 48
0
 def testSetExpiration(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("test", "1", 60, 2)
Ejemplo n.º 49
0
 def testConnect(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     self.assertEquals(True, c.is_connected())
     pass