def test_one_field_filter(sample_cube): spec = sample_cube.specification dimension = spec['dimensions'][1] category = dimension['categories'][1] filt = {dimension['id']: category['id']} filtered = sample_cube.filter(**filt) filtered_rows = map(dict, filtered.toEntries()) all_entries = map(dict, sample_cube.toEntries()) manual_filter = lambda row: row[dimension['id']] == category['id'] manually_filtered = filter(manual_filter, all_entries) assert len(filtered_rows) == len(manually_filtered) for a, b in zip(filtered_rows, manually_filtered): assert a == b
def test_dummy_filter(sample_cube): filtered = sample_cube.filter() assert sample_cube == filtered
def test_same_filtering_equals(sample_cube): a = sample_filtering(sample_cube) b = sample_filtering(sample_cube.filter()) assert a == b
def test_empty_filter_equals(sample_cube): assert sample_cube == sample_cube.filter()