make sure new stringref functions work

This commit is contained in:
J. Nick Koston
2026-01-17 08:35:46 -10:00
parent 65cdb97f06
commit 18c3dd8af7
2 changed files with 42 additions and 0 deletions

View File

@@ -24,12 +24,20 @@ async def test_select_stringref_trigger(
concatenated_future = loop.create_future()
comparison_future = loop.create_future()
index_logged_future = loop.create_future()
length_future = loop.create_future()
find_substr_future = loop.create_future()
find_char_future = loop.create_future()
substr_future = loop.create_future()
# Patterns to match in logs
value_pattern = re.compile(r"Select value: Option B")
concatenated_pattern = re.compile(r"Concatenated: Option B selected")
comparison_pattern = re.compile(r"Option B was selected")
index_pattern = re.compile(r"Select index: 1")
length_pattern = re.compile(r"Length: 8") # "Option B" is 8 chars
find_substr_pattern = re.compile(r"Found 'Option' in value")
find_char_pattern = re.compile(r"Space at position: 6") # space at index 6
substr_pattern = re.compile(r"Substr prefix: Option")
def check_output(line: str) -> None:
"""Check log output for expected messages."""
@@ -41,6 +49,14 @@ async def test_select_stringref_trigger(
comparison_future.set_result(True)
if not index_logged_future.done() and index_pattern.search(line):
index_logged_future.set_result(True)
if not length_future.done() and length_pattern.search(line):
length_future.set_result(True)
if not find_substr_future.done() and find_substr_pattern.search(line):
find_substr_future.set_result(True)
if not find_char_future.done() and find_char_pattern.search(line):
find_char_future.set_result(True)
if not substr_future.done() and substr_pattern.search(line):
substr_future.set_result(True)
async with (
run_compiled(yaml_config, line_callback=check_output),
@@ -71,6 +87,10 @@ async def test_select_stringref_trigger(
concatenated_future,
comparison_future,
index_logged_future,
length_future,
find_substr_future,
find_char_future,
substr_future,
),
timeout=5.0,
)
@@ -80,5 +100,9 @@ async def test_select_stringref_trigger(
"concatenated": concatenated_future.done(),
"comparison": comparison_future.done(),
"index_logged": index_logged_future.done(),
"length": length_future.done(),
"find_substr": find_substr_future.done(),
"find_char": find_char_future.done(),
"substr": substr_future.done(),
}
pytest.fail(f"StringRef operations failed - received: {results}")