from dockerredis import DockerRedis
from keepalive_tests import *  # noqa: We want all tests to run
from locate_tests import *  # noqa: We want all locate tests to run with the distributes configuration
from locate_tests import *  # noqa: We want all tests to run
from messagehandlerbuilder import (
    RedisConfig,
    StoreStrategy,
)
from redis import Redis
from register_tests import *  # noqa: We want all tests to run


@pytest.fixture(scope="module", autouse=True)
def redis():
    docker = DockerRedis()

    yield

    docker.stop()


@pytest.fixture(autouse=True)
def clean_redis(redis, redis_config):
    yield

    client = Redis(
        host=redis_config.host,
        port=redis_config.port,
        db=redis_config.db
    )
    client.flushdb()
    client.close()


@pytest.fixture
def store_strategy():
    return StoreStrategy.REDIS


@pytest.fixture()
def redis_config():
    return RedisConfig(
        host="localhost",
        port=6379,
        db=0,
        ssl=False,
    )
