def parse_result(self): agg = query.TagsAggregation() elasticsearch_result = { 'buckets': [ { 'key': 'tag-4', 'doc_count': 42 }, { 'key': 'tag-2', 'doc_count': 28 }, ] } assert agg(elasticsearch_result) == [ { 'tag': 'tag-4', 'count': 42 }, { 'tag': 'tag-2', 'count': 28 }, ]
def test_parse_result_with_empty(self): agg = query.TagsAggregation() assert agg.parse_result({}) == {}
def test_parse_result_with_none(self): agg = query.TagsAggregation() assert agg.parse_result(None) == {}
def test_it_allows_to_set_a_limit(self): agg = query.TagsAggregation(limit=14) assert agg({}) == { 'terms': {'field': 'tags_raw', 'size': 14} }
def test_elasticsearch_aggregation(self): agg = query.TagsAggregation() assert agg({}) == { 'terms': {'field': 'tags_raw', 'size': 0} }
def test_key_is_tags(self): assert query.TagsAggregation().key == 'tags'