Skip to content
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

Support NX/XX/CH flags in ZADD command #247

Merged
merged 4 commits into from
Aug 26, 2019

Conversation

adamantike
Copy link
Contributor

Add support for the new NX, XX, and CH flags in the ZADD command, which can only be provided with redis-py version 3 installed.

This fixes a subset of what's filed in #232. INCR flag will be implemented in a different pull request, as it's completely different to handle.

Add support for the new `NX`, `XX`, and `CH` flags in the `ZADD`
command, which can only be provided with `redis-py` version 3 installed.

This fixes a subset of what's filed in jamesls#232. `INCR` flag will be
implemented in a different pull request, as it's completely different to
handle.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 94.064% when pulling 2d8dcf3 on adamantike:zadd-with-nx-xx-ch into d675ee1 on jamesls:master.

@coveralls
Copy link

coveralls commented Aug 4, 2019

Coverage Status

Coverage increased (+0.03%) to 94.071% when pulling f019642 on adamantike:zadd-with-nx-xx-ch into d675ee1 on jamesls:master.

Copy link
Collaborator

@bmerry bmerry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good, just a few suggestions for strengthening the tests.

fakeredis/_server.py Show resolved Hide resolved
self.assertEqual(self.zadd('foo', {'four': 4, 'three': 3, 'zero': 0}, xx=True), 0)
self.assertEqual(self.redis.zrange('foo', 0, -1), [b'three', b'four'])
self.assertEqual(self.zadd('foo', {'two': 2, 'one': 1}, xx=True), 0)
self.assertEqual(self.redis.zrange('foo', 0, -1), [b'three', b'four'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a check that the scores do get updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the tests to use zrange with scores, and made them a bit more programmatic, to improve readability. Let me know what you think!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with that approach. What do you think about using a namedtuple rather than a dict with fixed keys to store the update information?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use namedtuples, thanks for the suggestion! Let me know if naming works for you :)

test_fakeredis.py Outdated Show resolved Hide resolved
@bmerry
Copy link
Collaborator

bmerry commented Aug 26, 2019

Looks good. Thanks for the contribution!

@bmerry bmerry merged commit 28a7591 into jamesls:master Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants