-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make code more abstract to pick from many future possible backends
Add stubs for redis and memory References #4 and references #6 Make default compatible with previous interface Now, the default is calculated dynamically to maintain previous behavior to default to pickle unless the ``mongetter`` argument is given. This makes it have the same behavior as before, so users aren't forced to change old code to use the ``backend`` argument Update docs Add tests
- Loading branch information
Showing
2 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Testing the MongoDB core of cachier.""" | ||
|
||
from cachier import cachier | ||
from cachier.core import MissingMongetter | ||
|
||
|
||
def test_bad_name(): | ||
"""Test that the appropriate exception is thrown when an invalid backend is given.""" | ||
name = 'nope' | ||
try: | ||
@cachier(backend=name) | ||
def func(): | ||
pass | ||
except ValueError as e: | ||
assert name in e.args[0] | ||
else: | ||
assert False | ||
|
||
|
||
def test_missing_mongetter(): | ||
"""Test that the appropriate exception is thrown when forgetting to specify the mongetter.""" | ||
try: | ||
@cachier(backend='mongo', mongetter=None) | ||
def func(): | ||
pass | ||
except MissingMongetter: | ||
assert True | ||
else: | ||
assert False |