FlowNotFound says whether a published flow or any flow is missing; read_all stamps its cache with the revision from before its scan; dashboard discard and delete commits name the key; a RedisState ttl expires counters and the names set too; bench_startup publishes the version after its saves, and only when there is a draft
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""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)
|
||||
Reference in New Issue
Block a user