mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-13 07:29:39 +00:00
Citadel: Add test for aggregation flattening
This commit is contained in:
parent
76d4c0562a
commit
967e146344
@ -155,7 +155,6 @@ def format_aggregations(aggregations, filters):
|
||||
key: {
|
||||
'label': str(filters[key]),
|
||||
'buckets': [{
|
||||
**bucket,
|
||||
'key': bucket['most_common']['buckets'][0]['key'] if 'most_common' in bucket else bucket['key'],
|
||||
'count': bucket['doc_count']
|
||||
} for bucket in value['buckets']]
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from indico_citadel.util import format_query, remove_none_entries
|
||||
from indico_citadel.util import _flatten, format_query, remove_none_entries
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('query', 'expected'), [
|
||||
@ -39,3 +39,13 @@ def test_query_placeholders(query, expected):
|
||||
])
|
||||
def test_remove_none_entries(val, expected):
|
||||
assert remove_none_entries(val) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('val', 'expected'), [
|
||||
({'person': {'name': {'buckets': []}, 'affiliation': {'buckets': []}}, 'other': {'other': {'buckets': []}}},
|
||||
{'person_name', 'person_affiliation', 'other_other'}),
|
||||
({'other': {'other': {'other': {'other': {'buckets': []}}}}},
|
||||
{'other_other_other_other'})
|
||||
])
|
||||
def test_flatten(val, expected):
|
||||
assert {key for key, _ in _flatten(val)} == expected
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user