Skip to content

Commit

Permalink
Fix get_facets to consistently return entire facet result
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Apr 24, 2019
1 parent 75c09f8 commit 9ed14ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion parasolr/query/queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def get_facets(self) -> Dict[str, Dict]:
query_opts['hl'] = False
# setting these by dictionary assignment, because conflicting
# kwargs results in a Python exception
return self.solr.query(**query_opts).facet_counts['facet_fields']
return self.solr.query(**query_opts).facet_counts

@staticmethod
def _lookup_to_filter(key: str, value: Any, tag: str='') -> str:
Expand Down
8 changes: 5 additions & 3 deletions parasolr/query/tests/test_queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ def test_get_facets(self, mockQR):
name, args, kwargs = mocksolr.query.mock_calls[0]
assert kwargs['rows'] == 0
assert not kwargs['hl']
# casts return to an OrderedDict
assert isinstance(ret, OrderedDict)
# returns a dict
assert isinstance(ret, dict)
# casts facet fields to an OrderedDict
assert isinstance(ret['facet_fields'], OrderedDict)
# return should be the return value of facet_counts.facet_fields
assert ret == OrderedDict(b=2)
assert ret['facet_fields'] == OrderedDict(b=2)

def test_filter(self):
mocksolr = Mock(spec=SolrClient)
Expand Down

0 comments on commit 9ed14ac

Please sign in to comment.