mockredis.client.MockRedis

Here are the examples of the python api mockredis.client.MockRedis taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

Example 1

Project: mockredis Source File: test_normalize.py
def test_normalize_command_name():
    cases = [
        ("DEL", "delete"),
        ("del", "delete"),
        ("ping", "ping"),
        ("PING", "ping"),
    ]

    def _test(command, expected):
        redis = MockRedis()
        eq_(redis._normalize_command_name(command), expected)

    for command, expected in cases:
        yield _test, command, expected

Example 2

Project: mockredis Source File: test_normalize.py
def test_normalize_command_response():

    cases = [
        ("get", "foo", "foo"),
        ("zrevrangebyscore", [(1, 2), (3, 4)], [1, 2, 3, 4]),
    ]

    def _test(command, response, expected):
        redis = MockRedis()
        eq_(redis._normalize_command_response(command, response), expected)

    for command, response, expected in cases:
        yield _test, command, response, expected

Example 3

Project: mockredis Source File: test_normalize.py
def test_normalize_command_args():

    cases = [
        (False, "zadd", ("key", "member", 1.0), ("key", 1.0, "member")),
        (True, "zadd", ("key", 1.0, "member"), ("key", 1.0, "member")),

        (True, "zrevrangebyscore",
         ("key", "inf", "-inf"),
         ("key", "inf", "-inf")),

        (True, "zrevrangebyscore",
         ("key", "inf", "-inf", "limit", 0, 10),
         ("key", "inf", "-inf", 0, 10, False)),

        (True, "zrevrangebyscore",
         ("key", "inf", "-inf", "withscores"),
         ("key", "inf", "-inf", None, None, True)),

        (True, "zrevrangebyscore",
         ("key", "inf", "-inf", "withscores", "limit", 0, 10),
         ("key", "inf", "-inf", 0, 10, True)),

        (True, "zrevrangebyscore",
         ("key", "inf", "-inf", "WITHSCORES", "LIMIT", 0, 10),
         ("key", "inf", "-inf", 0, 10, True)),
    ]

    def _test(strict, command, args, expected):
        redis = MockRedis(strict=strict)
        eq_(tuple(redis._normalize_command_args(command, *args)), expected)

    for strict, command, args, expected in cases:
        yield _test, strict, command, args, expected