mirror of
https://github.com/jazzband/django-constance.git
synced 2026-05-09 16:14:47 +00:00
Used abstract base class for backend to simplify code coverage
This commit is contained in:
parent
5a9f4162d3
commit
81a66c78e9
1 changed files with 16 additions and 7 deletions
|
|
@ -1,39 +1,48 @@
|
|||
"""Defines the base constance backend."""
|
||||
|
||||
from abc import ABC
|
||||
from abc import abstractmethod
|
||||
|
||||
class Backend:
|
||||
|
||||
class Backend(ABC):
|
||||
@abstractmethod
|
||||
def get(self, key):
|
||||
"""
|
||||
Get the key from the backend store and return the value.
|
||||
Return None if not found.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
async def aget(self, key):
|
||||
"""
|
||||
Get the key from the backend store and return the value.
|
||||
Return None if not found.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def mget(self, keys):
|
||||
"""
|
||||
Get the keys from the backend store and return a list of the values.
|
||||
Return an empty list if not found.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
async def amget(self, keys):
|
||||
"""
|
||||
Get the keys from the backend store and return a list of the values.
|
||||
Return an empty list if not found.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def set(self, key, value):
|
||||
"""Add the value to the backend store given the key."""
|
||||
raise NotImplementedError
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
async def aset(self, key, value):
|
||||
"""Add the value to the backend store given the key."""
|
||||
raise NotImplementedError
|
||||
...
|
||||
|
|
|
|||
Loading…
Reference in a new issue