Closed wasperen2 closed 2 months ago
Oops 🙊. We probably should have made the redis_store
property a read-only property.
The expectation was the RedisConfig was the only way to initialize the redis instance.
For passing a mock redis instance, @wasperen2 , in your use case, are you able to use the way it was done in the test/conftest.py
file?
i.e.
Closed this as fixed by the another pull request, assuming the solution provided in the previous comment handles @wasperen2 use case
As per my comments, can we please reconsider this and stick with the option to do Dependency Injection (https://en.wikipedia.org/wiki/Dependency_injection)? Having that ability makes your package play better with larger systems where injecting core services is common. This results in more cohesive code and a more standard way of deploying and testing.
(it would also not introduce a breaking change :))
@wasperen2 I think we should close the current issue first, which is the ambiguity problem. #35 closes this sufficiently because it is in line with the original idea of how the store were to be initialized (as can be seen in all current examples and tests).
We can then take your suggestion for ability to pass in a pre-constructed redis instance as new feature request. If you haven't already, please create a new issue with this feature request so that we can weigh its return-on-investment.
Describe the bug One can pass a Redis instance when a new Store is created. And, although
self.redis_store
is initially set to that value, it is brutally overwritten by a new Redis instance created from the passed config.This makes it harder to pass in a Mock Redis instance for creating unit tests. It is also unexpected behavior.
To Reproduce
Expected behavior I would expect the Redis store that I passed in, to be used rather than another one.