Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #20.
- Loading branch information
Showing
3 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import fudge | ||
|
||
from oedipus import S | ||
from oedipus.tests import no_results, Biscuit, BaseSphinxMeta | ||
|
||
import sphinxapi | ||
|
||
|
||
class BiscuitWithGroupBy(object): | ||
"""Biscuit with default groupby""" | ||
|
||
class SphinxMeta(BaseSphinxMeta): | ||
group_by = ('a', '@group') | ||
|
||
|
||
@fudge.patch('sphinxapi.SphinxClient') | ||
def test_group_by(sphinx_client): | ||
"""Test group by.""" | ||
(sphinx_client.expects_call().returns_fake() | ||
.is_a_stub() | ||
.expects('SetGroupBy') | ||
.with_args('a', sphinxapi.SPH_GROUPBY_ATTR, '@group DESC') | ||
.expects('RunQueries') | ||
.returns(no_results)) | ||
S(Biscuit).group_by('a', '-@group')._raw() | ||
|
||
|
||
@fudge.patch('sphinxapi.SphinxClient') | ||
def test_group_by_asc(sphinx_client): | ||
"""Test group by ascending.""" | ||
(sphinx_client.expects_call().returns_fake() | ||
.is_a_stub() | ||
.expects('SetGroupBy') | ||
.with_args('a', sphinxapi.SPH_GROUPBY_ATTR, '@group ASC') | ||
.expects('RunQueries') | ||
.returns(no_results)) | ||
S(Biscuit).group_by('a', '@group')._raw() | ||
|
||
|
||
@fudge.patch('sphinxapi.SphinxClient') | ||
def test_group_by_override(sphinx_client): | ||
"""Test group by override.""" | ||
(sphinx_client.expects_call().returns_fake() | ||
.is_a_stub() | ||
.expects('SetGroupBy') | ||
.with_args('a', sphinxapi.SPH_GROUPBY_ATTR, '@group ASC') | ||
.expects('RunQueries') | ||
.returns(no_results)) | ||
# The second call overrides the first one. | ||
S(Biscuit).group_by('b', '-@group').group_by('a', '@group')._raw() | ||
|
||
|
||
@fudge.patch('sphinxapi.SphinxClient') | ||
def test_group_by_sphinxmeta(sphinx_client): | ||
"""Test group by from SphinxMeta.""" | ||
(sphinx_client.expects_call().returns_fake() | ||
.is_a_stub() | ||
.expects('SetGroupBy') | ||
.with_args('a', sphinxapi.SPH_GROUPBY_ATTR, '@group ASC') | ||
.expects('RunQueries') | ||
.returns(no_results)) | ||
S(BiscuitWithGroupBy)._raw() |