"""Django models for the ``limpyd_database`` tests"""

from django.db import models
from django.utils.functional import cached_property

from mtp.apps.common.limpyd_base import RedisBackedDjangoModel, RedisBackedDjangoModelWithLogs
from mtp.apps.common.models import UUIDPkModel


class DjangoTestModel(UUIDPkModel, RedisBackedDjangoModel):
    """Simple limpyd model to test the django-limpyd connection

    Attributes
    ----------
    id : instance of ``django_extensions.db.fields.UUIDField``
        The primary key of the model to be as close as possible as mtp models

    some_field : django field, instance of ``django.db.models.CharField``
        Simply used to store data to test

    """

    some_field = models.CharField(max_length=255)

    @cached_property
    def redis_model(self):
        """Get the limpyd model to link this django model to

        Returns
        -------
        RedisTestModel
            The ``limpyd_base.limpyd_models.RedisTestModel`` model
        """
        from .limpyd_models import RedisTestModel
        return RedisTestModel


class DjangoTestModelWithLogs(UUIDPkModel, RedisBackedDjangoModelWithLogs):
    """Simple limpyd model to test the logs capability of the ``RedisBackedDjangoModelWithLogs``"""

    @cached_property
    def redis_model(self):
        """Get the limpyd model to link this django model to

        Returns
        -------
        RedisTestModelwithLogs
            The ``limpyd_base.limpyd_models.RedisTestModelWithLogs`` model
        """

        from .limpyd_models import RedisTestModelwithLogs
        return RedisTestModelwithLogs
