from mockredis import MockRedis as _MockRedis

from .generic import GenericCommandsMixin
from .hash import HashCommandsMixin
from .list import ListCommandsMixin
from .set import SetCommandsMixin

__all__ = ['MockRedis']


class MockRedis(GenericCommandsMixin, HashCommandsMixin, ListCommandsMixin, SetCommandsMixin):
    """Fake high-level aioredis.Redis interface"""

    def __init__(self, connection=None, encoding=None, **kwargs):

        # Just for API compatibility
        self._conn = connection
        self._redis = _MockRedis(**kwargs)

        self._encoding = encoding


async def create_redis(address, *, db=None, password=None, ssl=None,
                       encoding=None, commands_factory=MockRedis,
                       loop=None):
    '''Create a fake high-level MockRedis interface

    This function is a coroutine
    '''
    return commands_factory(None, encoding=encoding)

from mockredis import MockRedis as _MockRedis

from .generic import GenericCommandsMixin
from .hash import HashCommandsMixin
from .list import ListCommandsMixin
from .set import SetCommandsMixin

__all__ = ['MockRedis']


class MockRedis(GenericCommandsMixin, HashCommandsMixin, ListCommandsMixin, SetCommandsMixin):
    """Fake high-level aioredis.Redis interface"""

    def __init__(self, connection=None, encoding=None, **kwargs):

        # Just for API compatibility
        self._conn = connection
        self._redis = _MockRedis(**kwargs)

        self._encoding = encoding

    async def wait_closed(self):
        if self._conn:
            await self._conn.wait_closed()

    def close(self):
        if self._conn:
            self._conn.close()

async def create_redis(address, *, db=None, password=None, ssl=None,
                       encoding=None, commands_factory=MockRedis,
                       loop=None):
    '''Create a fake high-level MockRedis interface

    This function is a coroutine
    '''
    return commands_factory(None, encoding=encoding)

Add close comands to MockRedis class
chore: Add close comands to MockRedis class

This closes #15

Signed-off-by: Kai Blin <ad3597797f6179d503c382b2627cc19939309418@biosustain.dtu.dk>

  from mockredis import MockRedis as _MockRedis
  
  from .generic import GenericCommandsMixin
  from .hash import HashCommandsMixin
  from .list import ListCommandsMixin
  from .set import SetCommandsMixin
  
  __all__ = ['MockRedis']
  
  
  class MockRedis(GenericCommandsMixin, HashCommandsMixin, ListCommandsMixin, SetCommandsMixin):
      """Fake high-level aioredis.Redis interface"""
  
      def __init__(self, connection=None, encoding=None, **kwargs):
  
          # Just for API compatibility
          self._conn = connection
          self._redis = _MockRedis(**kwargs)
  
          self._encoding = encoding
  
+     async def wait_closed(self):
+         if self._conn:
+             await self._conn.wait_closed()
+ 
+     def close(self):
+         if self._conn:
+             self._conn.close()
  
  async def create_redis(address, *, db=None, password=None, ssl=None,
                         encoding=None, commands_factory=MockRedis,
                         loop=None):
      '''Create a fake high-level MockRedis interface
  
      This function is a coroutine
      '''
      return commands_factory(None, encoding=encoding)
  
Add close comands to MockRedis class
## Code Before:
from mockredis import MockRedis as _MockRedis

from .generic import GenericCommandsMixin
from .hash import HashCommandsMixin
from .list import ListCommandsMixin
from .set import SetCommandsMixin

__all__ = ['MockRedis']


class MockRedis(GenericCommandsMixin, HashCommandsMixin, ListCommandsMixin, SetCommandsMixin):
    """Fake high-level aioredis.Redis interface"""

    def __init__(self, connection=None, encoding=None, **kwargs):

        # Just for API compatibility
        self._conn = connection
        self._redis = _MockRedis(**kwargs)

        self._encoding = encoding


async def create_redis(address, *, db=None, password=None, ssl=None,
                       encoding=None, commands_factory=MockRedis,
                       loop=None):
    '''Create a fake high-level MockRedis interface

    This function is a coroutine
    '''
    return commands_factory(None, encoding=encoding)

## Instruction:
Add close comands to MockRedis class
## Code After:
from mockredis import MockRedis as _MockRedis

from .generic import GenericCommandsMixin
from .hash import HashCommandsMixin
from .list import ListCommandsMixin
from .set import SetCommandsMixin

__all__ = ['MockRedis']


class MockRedis(GenericCommandsMixin, HashCommandsMixin, ListCommandsMixin, SetCommandsMixin):
    """Fake high-level aioredis.Redis interface"""

    def __init__(self, connection=None, encoding=None, **kwargs):

        # Just for API compatibility
        self._conn = connection
        self._redis = _MockRedis(**kwargs)

        self._encoding = encoding

    async def wait_closed(self):
        if self._conn:
            await self._conn.wait_closed()

    def close(self):
        if self._conn:
            self._conn.close()

async def create_redis(address, *, db=None, password=None, ssl=None,
                       encoding=None, commands_factory=MockRedis,
                       loop=None):
    '''Create a fake high-level MockRedis interface

    This function is a coroutine
    '''
    return commands_factory(None, encoding=encoding)
