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

Test FakeRedis against real Redis #900

Merged
merged 10 commits into from
Mar 4, 2015

Conversation

jerith
Copy link
Member

@jerith jerith commented Mar 2, 2015

There are a number of differences between the behaviours of FakeRedis and a real Redis client+server combination. We really should run the same set of tests for both and fix the differences.

@jerith jerith added the testing label Jan 27, 2015
@jerith
Copy link
Member Author

jerith commented Mar 2, 2015

Whoops, I left some tests commented. I'll fix that shortly.



# TestFakeRedisVerify.skip = "foo"
# TestFakeRedisVerifyAsync.skip = "foo"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these be here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, thanks. I'll remove them.

@justinvdm
Copy link
Contributor

Would it be worth running the vumi-go tests using the fake redis changes? Not sure if that needs to be done before this PR lands though.

@jerith
Copy link
Member Author

jerith commented Mar 2, 2015

Would it be worth running the vumi-go tests using the fake redis changes? Not sure if that needs to be done before this PR lands though.

Good idea, I'll do that now. Thanks!

@jerith
Copy link
Member Author

jerith commented Mar 2, 2015

vumi-go is happy with the new fake Redis. (Most of the changes were response values on write operations, so we were pretty much ignoring them anyway.)

@justinvdm
Copy link
Contributor

vumi-go is happy with the new fake Redis. (Most of the changes were response values on write operations, so we were pretty much ignoring them anyway.)

Awesome, thanks for checking.

Scanning returns keys in an order that depends on arbitrary state in
the Redis server, so we can't fake it in a way that's identical to real
Redis.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

I would've thought testing this against both fake and real redis is possible if we just sort the returned keys before asserting on them (along with a docstring explaining why sorting is necessary in the test). Any reason why that wouldn't work that I'm missing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, right, we can't assume that a set of keys returned by a real redis scan call will always be the same set of keys. For some reason I assumed that would be the case, nevermind.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. I tried to rewrite the tests in a way that would let us walk the scan over the whole set of keys and check that we got the same set of results at the end, but that ended up being more effort than it's really worth.

@justinvdm
Copy link
Contributor

I might just be not finding it in the diff, I don't think we have tests for set (including making sure that we turn OKs into Trues). Could we add test(s) for it?

@justinvdm
Copy link
Contributor

Looks good, left some comments.

@jerith
Copy link
Member Author

jerith commented Mar 3, 2015

I might just be not finding it in the diff, I don't think we have tests for set (including making sure that we turn OKs into Trues). Could we add test(s) for it?

I'd prefer to leave that for another branch -- the purpose of this one is to build the verification infrastructure. I only added new tests for things that changed in ways that required modifications to other tests, like lpush and rpush. There are probably a bunch of other methods that aren't being tested explicitly (or perhaps even at all) and I don't want this branch to get too big.

@justinvdm
Copy link
Contributor

I'd prefer to leave that for another branch -- the purpose of this one is to build the verification infrastructure. I only added new tests for things that changed in ways that required modifications to other tests, like lpush and rpush. There are probably a bunch of other methods that aren't being tested explicitly (or perhaps even at all) and I don't want this branch to get too big.

Happy for that to happen in a separate PR

try:
value = int(value) + int(str(amount))
except (TypeError, ValueError):
raise ResponseError("value is not an integer or out of range")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have tests for these cases:

  • using "0" as the default field
  • hincrby against a key holding the wrong kind of value
  • hincrby with a non-integer or out of range value

If not, could we add some?

Copy link
Member Author

Choose a reason for hiding this comment

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

Theses cases are all covered in test_hincrby.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, missed those.

@justinvdm
Copy link
Contributor

👍 when travis is happy.

Should we make tickets for RedisPairWrapper and set tests?

@jerith
Copy link
Member Author

jerith commented Mar 4, 2015

I opened #926 for the test coverage improvements.

@jerith jerith merged commit 967bccc into develop Mar 4, 2015
@jerith jerith deleted the feature/issue-900-verify-fake-redis branch March 4, 2015 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants