-
Notifications
You must be signed in to change notification settings - Fork 158
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
Disable decorators cache per-call #404
Conversation
Codecov Report
@@ Coverage Diff @@
## master #404 +/- ##
==========================================
+ Coverage 99.76% 99.77% +<.01%
==========================================
Files 9 9
Lines 866 871 +5
Branches 91 95 +4
==========================================
+ Hits 864 869 +5
Misses 2 2
Continue to review full report at Codecov.
|
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.
Nice one! only minor modifications
aiocache/decorators.py
Outdated
@@ -72,14 +72,19 @@ def __call__(self, f): | |||
return wrapper | |||
|
|||
async def decorator(self, f, *args, **kwargs): | |||
disable_read = kwargs.pop('aiocache_disable_read', False) | |||
disable_write = kwargs.pop('aiocache_disable_write', False) |
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.
Put explicitly in the function
signature please
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.
Also, add docs about those two new parameters in the class docstring or in decorators.rst
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.
Done
tests/ut/test_decorators.py
Outdated
@@ -94,6 +94,37 @@ def test_get_cache_key_with_key_builder(self, decorator): | |||
assert decorator.cache.set.call_count == 0 | |||
assert stub.call_count == 0 | |||
|
|||
@pytest.mark.asyncio | |||
async def test_disable_read(self, decorator, decorator_call): | |||
decorator.cache.get = CoroutineMock(return_value=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.
Why do you need this if its not being called?
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.
Probably from copy&pasting, removed
tests/ut/test_decorators.py
Outdated
@@ -434,6 +465,38 @@ def test_get_cache_keys_with_key_builder(self, decorator): | |||
with pytest.raises(Exception): | |||
assert await decorator_call(keys=[]) | |||
|
|||
@pytest.mark.asyncio | |||
async def test_disable_read(self, decorator, decorator_call): | |||
decorator.cache.multi_get = CoroutineMock(return_value=[1, 2]) |
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.
same, not needed because its not being called?
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.
Removed
Yeah I thought the same... Maybe |
MR for #386
Not convinced about the naming (too long?), I'm open to suggestions.
Regarding the documentation, I am not sure where to put it since the docstring in the decorator is only for parameters for the decorator itself, and not calls to the decorator.