예제 #1
0
def test_set_exists_get_delete(redis):
    store = RedisObjectStore(namespace='test', redis_client=redis)

    #
    # Assert that what we put in is what we get out
    #
    store.set('my_key', data_1)

    #
    # Assert that the object exists in the store
    #
    assert store.exists('my_key')

    #
    # Assert that what we put in is what we get out
    #
    assert store.get('my_key') == data_1

    #
    # Assert that a deletion actually deletes the object
    #
    store.delete('my_key')
    assert not store.exists('my_key')
    assert store.get('my_key') is None
예제 #2
0
def test_namespace(redis):
    store_1 = RedisObjectStore(namespace='test_1', redis_client=redis)
    store_2 = RedisObjectStore(namespace='test_2', redis_client=redis)

    #
    # Assert that there are no name collisions for different namespaces
    #
    store_1.set('my_key', data_1)
    store_2.set('my_key', data_2)
    assert store_1.get('my_key') == data_1
    assert store_2.get('my_key') == data_2

    #
    # Assert that objects added to one namespace do not show up in another
    #
    store_1.set('another_key', data_1)
    assert not store_2.exists('another_key')
    assert store_2.get('another_key') is None