Used abstract base class for backend to simplify code coverage

This commit is contained in:
Philipp Thumfart 2026-03-02 16:55:29 +01:00
parent 5a9f4162d3
commit 81a66c78e9

View file

@ -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
...