def test_data_cache_store_item(): """ Test data cache storing `n23.Data` item. """ cache = Cache(['n']) cache.add(Data('n', 10, 1001, 101)) assert [(1001, 101)] == list(cache['n'])
def test_data_cache_store_dict(): """ Test data cache storing dictionary item. """ cache = Cache(['n']) cache.add({'name': 'n', 'clock': 10, 'time': 1001, 'value': 101}) assert [(1001, 101)] == list(cache['n'])
def test_data_cache_store_list(): """ Test data cache storing list of items. """ cache = Cache(['n']) cache.add({'name': 'n', 'clock': 10, 'time': 1001, 'value': 101}) cache.add(Data('n', 11, 1002, 102)) assert [(1001, 101), (1002, 102)] == list(cache['n'])
def test_data_cache_store_limit(): """ Test data cache storing no more than max size items. """ cache = Cache(['n'], 2) # store just two items cache.add(Data('n', 10, 1001, 101)) cache.add(Data('n', 11, 1002, 102)) cache.add(Data('n', 12, 1003, 103)) cache.add(Data('n', 13, 1004, 104)) assert [(1003, 103), (1004, 104)] == list(cache['n'])