Beispiel #1
0
def test_cache_manager_len(store, expected):
    """Test that iter iterates over entire internal dict properly.

    Args:
        store: the internal dictionary to use.

    """
    from foreshadow.cachemanager import CacheManager

    cs = CacheManager()
    cs.store = store
    assert len(cs) == expected
Beispiel #2
0
def test_cache_manager_iter(store):
    """Test that iter iterates over entire internal dict properly.

    Args:
        store: the internal dictionary to use.

    """
    from foreshadow.cachemanager import CacheManager

    cs = CacheManager()
    cs.store = store
    expected = {}  # we try to recreate the internal dict using the keys
    for key in iter(cs):
        if expected.get(key[0], None) is None:
            expected[key[0]] = {}
        if key[1] is None:
            expected[key[0]] = cs[key]
        else:
            expected[key[0]][key[1]] = cs[key]
    assert expected == cs.store