Exemplo n.º 1
0
def test_delete(docker_redis):
    cache = QueryCache(REDIS_HOST, REDIS_PORT)

    table_name = "test table"
    key = "insert/entityType/type"
    value = 'string'

    cache.put(table_name, key, value)
    assert cache.get(table_name, key) == value
    cache.delete(table_name, key)
    assert cache.get(table_name, key) is None

    cache.flushall()
Exemplo n.º 2
0
def test_expire():
    cache = QueryCache(REDIS_HOST, REDIS_PORT)

    table_name = "test table"
    key = "insert/entityType/type"
    value = 'string'

    cache.put(table_name, key, value, 1)
    assert cache.get(table_name, key) == str(value)
    sleep(5)
    assert cache.get(table_name, key) is None

    cache.flushall()
Exemplo n.º 3
0
def test_null_value(docker_redis):
    cache = QueryCache(REDIS_HOST, REDIS_PORT)

    table_name = "test table"
    key1 = "insert/entityType/type"
    key2 = "/v2/entities/type"

    value1 = 'string'
    value2 = None

    cache.put(table_name, key1, value1)
    cache.put(table_name, key2, value2)

    assert cache.get(table_name, key1) == value1
    assert cache.get(table_name, key2) == value2

    cache.flushall()
Exemplo n.º 4
0
def test_null_key(docker_redis):
    cache = QueryCache(REDIS_HOST, REDIS_PORT)

    table_name = ""
    key1 = "insert/entityType/type"
    key2 = ""

    value1 = 'string'
    value2 = {'dic': 2}

    cache.put(table_name, key1, value1)
    cache.put(table_name, key2, value2)

    assert cache.get(table_name, key1) == value1
    assert cache.get(table_name, key2) == value2

    cache.flushall()
Exemplo n.º 5
0
def test_insert():
    cache = QueryCache(REDIS_HOST, REDIS_PORT)

    table_name = "test table"
    key1 = "insert/entityType/type"
    key2 = "/v2/entities/type"

    value1 = 'string'
    value2 = {'dic': 2}

    cache.put(table_name, key1, value1)
    cache.put(table_name, key2, value2)

    assert cache.get(table_name, key1) == str(value1)
    assert cache.get(table_name, key2) == str(value2)

    cache.flushall()