Пример #1
0
def test_get_many_set_many():
    client = MockMemcacheClient()
    client.set("h", 1)

    tools.assert_equal(client.get_many("hello"), {"h" : 1})

    client.set_many(dict(h=1, e=2, l=3))
    tools.assert_equal(client.get_many("hello"), dict(h=1, e=2, l=3))
Пример #2
0
def test_get_many_set_many():
    client = MockMemcacheClient()
    client.set(b"h", 1)

    tools.assert_equal(client.get_many([b"h", b"e", b"l", b"o"]), {b"h": 1})

    # Convert keys into bytes
    d = dict(
        (k.encode('ascii'), v) for k, v in six.iteritems(dict(h=1, e=2, l=3)))
    client.set_many(d)
    tools.assert_equal(client.get_many([b"h", b"e", b"l", b"o"]), d)
Пример #3
0
def test_get_many_set_many():
    client = MockMemcacheClient()
    client.set(b"h", 1)

    result = client.get_many([b"h", b"e", b"l", b"o"])
    assert result == {b"h": 1}

    # Convert keys into bytes
    d = {k.encode("ascii"): v for k, v in dict(h=1, e=2, z=3).items()}
    client.set_many(d)
    assert client.get_many([b"h", b"e", b"z", b"o"]) == d
Пример #4
0
def test_get_many_set_many():
    client = MockMemcacheClient()
    client.set(b"h", 1)

    result = client.get_many([b"h", b"e", b"l", b"o"])
    assert result == {b"h": 1}

    # Convert keys into bytes
    d = dict(
        (k.encode('ascii'), v) for k, v in six.iteritems(dict(h=1, e=2, l=3)))
    client.set_many(d)
    assert client.get_many([b"h", b"e", b"l", b"o"]) == d
Пример #5
0
def test_get_many_set_many():
    client = MockMemcacheClient()
    client.set(b"h", 1)

    result = client.get_many([b"h", b"e", b"l", b"o"])
    assert result == {b"h": 1}

    # Convert keys into bytes
    d = dict((k.encode('ascii'), v)
             for k, v in six.iteritems(dict(h=1, e=2, z=3)))
    client.set_many(d)
    assert client.get_many([b"h", b"e", b"z", b"o"]) == d
Пример #6
0
def test_get_many_set_many_non_ascii_values():
    client = MockMemcacheClient()

    # These are the values of calling msgpack.packb() on '1', '2', and '3'
    non_ascii_1 = b'\xa11'
    non_ascii_2 = b'\xa12'
    non_ascii_3 = b'\xa13'
    client.set(b"h", non_ascii_1)

    result = client.get_many([b"h", b"e", b"l", b"o"])
    assert result == {b"h": non_ascii_1}

    # Convert keys into bytes
    d = dict((k.encode('ascii'), v) for k, v in six.iteritems(
        dict(h=non_ascii_1, e=non_ascii_2, z=non_ascii_3)))
    client.set_many(d)
    assert client.get_many([b"h", b"e", b"z", b"o"]) == d
Пример #7
0
def test_get_many_set_many_non_ascii_values():
    client = MockMemcacheClient()

    # These are the values of calling msgpack.packb() on '1', '2', and '3'
    non_ascii_1 = b"\xa11"
    non_ascii_2 = b"\xa12"
    non_ascii_3 = b"\xa13"
    client.set(b"h", non_ascii_1)

    result = client.get_many([b"h", b"e", b"l", b"o"])
    assert result == {b"h": non_ascii_1}

    # Convert keys into bytes
    d = {
        k.encode("ascii"): v
        for k, v in dict(h=non_ascii_1, e=non_ascii_2, z=non_ascii_3).items()
    }
    client.set_many(d)
    assert client.get_many([b"h", b"e", b"z", b"o"]) == d
Пример #8
0
def test_get_many_set_many_non_ascii_values():
    client = MockMemcacheClient()

    # These are the values of calling msgpack.packb() on '1', '2', and '3'
    non_ascii_1 = b'\xa11'
    non_ascii_2 = b'\xa12'
    non_ascii_3 = b'\xa13'
    client.set(b"h", non_ascii_1)

    result = client.get_many([b"h", b"e", b"l", b"o"])
    assert result == {b"h": non_ascii_1}

    # Convert keys into bytes
    d = dict((k.encode('ascii'), v)
             for k, v in six.iteritems(
                dict(h=non_ascii_1, e=non_ascii_2, z=non_ascii_3)
             ))
    client.set_many(d)
    assert client.get_many([b"h", b"e", b"z", b"o"]) == d