Пример #1
0
def test_get_set_non_ascii_value():
    client = MockMemcacheClient()
    assert client.get(b"hello") is None

    # This is the value of msgpack.packb('non_ascii')
    non_ascii_str = b'\xa9non_ascii'
    client.set(b"hello", non_ascii_str)
    assert client.get(b"hello") == non_ascii_str
Пример #2
0
def test_incr_decr():
    client = MockMemcacheClient()

    client.add(b"k", 2)

    client.incr(b"k", 4)
    assert client.get(b"k") == 6

    client.decr(b"k", 2)
    assert client.get(b"k") == 4
Пример #3
0
def test_incr_decr():
    client = MockMemcacheClient()

    client.add("k", 2)

    client.incr("k", 4)
    tools.assert_equal(client.get("k"), 6)

    client.decr("k", 2)
    tools.assert_equal(client.get("k"), 4)
Пример #4
0
def test_delete():
    client = MockMemcacheClient()

    client.add(b"k", 2)
    assert client.get(b"k") == 2

    client.delete(b"k")
    assert client.get(b"k") is None
Пример #5
0
def test_add():
    client = MockMemcacheClient()

    client.add(b"k", 2)
    assert client.get(b"k") == 2

    client.add(b"k", 25)
    assert client.get(b"k") == 2