"""RedisState against a real server, enabled by FLUKSIO_TEST_REDIS_HOST (and optional PORT).""" import os import uuid import pytest from fluksio.flow.state import RedisState @pytest.fixture def state(): host = os.environ.get("FLUKSIO_TEST_REDIS_HOST") if not host: pytest.skip("Set FLUKSIO_TEST_REDIS_HOST to run Redis integration checks") port = int(os.environ.get("FLUKSIO_TEST_REDIS_PORT", "6379")) state = RedisState(host, port, namespace=f"test-state-{uuid.uuid4().hex}", ttl=600) try: yield state finally: state.clear() state.close() def test_a_ttl_expires_counters_and_the_names_set(state): state.set("heat.temp", 21) state.increment("__version__:heat.a") state.increment_multi(["__version__:heat.b"]) state.record({"heat.v": 1}, {}, ["__version__:heat.c"], 0.0) keys = state.keys() assert "__names__" in keys and "__version__:heat.c" in keys assert all(state._client.ttl(state._key(k)) > 0 for k in keys)