-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TIMEOUT to query class #2519
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d5d3271
add timeout to query class
shacharPash 023b533
Add test_timeout
shacharPash a8f4443
fix lines
shacharPash 1e27631
fix format
shacharPash 3dc11af
add test & fixes
shacharPash d0c9635
merge tests
shacharPash 5f00869
change timeout to not_a_number
shacharPash 8b7181f
change q1 to q2
shacharPash 55b1955
Fix async method
shacharPash File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1001,3 +1001,16 @@ async def test_search_commands_in_pipeline(modclient: redis.Redis): | |
assert "doc2" == res[3][4] | ||
assert res[3][5] is None | ||
assert res[3][3] == res[3][6] == ["txt", "foo bar"] | ||
|
||
|
||
@pytest.mark.redismod | ||
def test_timeout(): | ||
q1 = Query("foo").timeout(5000) | ||
assert q1.get_args() == ["foo", "TIMEOUT", 5000, "LIMIT", 0, 10] | ||
|
||
|
||
@pytest.mark.redismod | ||
def test_not_number_timeout(modclient: redis.Redis): | ||
q1 = Query("foo").timeout("not a number") | ||
with pytest.raises(Exception): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to check for a more specific error |
||
modclient.ft().search(q1) |
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 |
---|---|---|
|
@@ -1615,3 +1615,16 @@ def test_withsuffixtrie(modclient: redis.Redis): | |
waitForIndex(modclient, getattr(modclient.ft(), "index_name", "idx")) | ||
info = modclient.ft().info() | ||
assert "WITHSUFFIXTRIE" in info["attributes"][0] | ||
|
||
|
||
@pytest.mark.redismod | ||
def test_timeout(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as the async tests... |
||
q1 = Query("foo").timeout(5000) | ||
assert q1.get_args() == ["foo", "TIMEOUT", 5000, "LIMIT", 0, 10] | ||
|
||
|
||
@pytest.mark.redismod | ||
def test_not_number_timeout(modclient: redis.Redis): | ||
q1 = Query("foo").timeout("not a number") | ||
with pytest.raises(Exception): | ||
modclient.ft().search(q1) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shacharPash Can you combine the 2 tests into one and rename it to test_query_timeout?