-
Notifications
You must be signed in to change notification settings - Fork 53
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
Python: adds PTTL command #1036
Conversation
@@ -926,14 +926,15 @@ async def test_unlink(self, redis_client: TRedisClient): | |||
|
|||
@pytest.mark.parametrize("cluster_mode", [True, False]) | |||
@pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) | |||
async def test_expire_pexpire_ttl_with_positive_timeout( | |||
async def test_expire_pexpire_ttl_pttl_with_positive_timeout( |
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.
please tell me if you prefer:
@pytest.mark.parametrize("cluster_mode", [True, False])
@pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3])
async def test_pttl(self, redis_client: TRedisClient):
key = get_random_string(10)
assert await redis_client.pttl(key) == -2
current_time = int(time.time())
assert await redis_client.set(key, "value") == OK
assert await redis_client.pttl(key) == -1
assert await redis_client.expire(key, 10) == True
assert 0 < await redis_client.pttl(key) <= 10000
assert await redis_client.expireat(key, current_time + 20) == True
assert 0 < await redis_client.pttl(key) <= 20000
assert await redis_client.pexpireat(key, current_time * 1000 + 30000) == True
assert 0 < await redis_client.pttl(key) <= 30000
# set command clears the timeout.
assert await redis_client.set(key, "value") == OK
assert await redis_client.pttl(key) == -1
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.
Yes, separating the command to a different test will help debugging if needed later on. The last check though seems duplicated (set and then asserting again that its PTTL is -1)
a80f28d
to
3857d09
Compare
@@ -1005,7 +1005,7 @@ async def expire( | |||
|
|||
Examples: | |||
>>> await client.expire("my_key", 60) | |||
1 # Indicates that a timeout of 60 seconds has been set for "my_key." | |||
True # Indicates that a timeout of 60 seconds has been set for "my_key." |
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.
May be move doc fixes to another PR?
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.
+1 for next time, for now just make sure to have these changes in a separate commit
else: | ||
assert ( | ||
await redis_client.expireat( | ||
key, current_time + 50, ExpireOptions.NewExpiryGreaterThanCurrent | ||
) | ||
== 1 | ||
== True |
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.
You can do assert await ...
without == True
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.
Please separate the tests
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.