Files
cachier/tests/test_core_lookup.py
Charles Tapley Hoyt 000f3212d9 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
2020-11-25 14:02:41 +02:00

30 lines
720 B
Python

"""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