From 2f7d003d27d277c510ae60d85fc98f922a5e6d42 Mon Sep 17 00:00:00 2001 From: Karthic Raghupathi Date: Wed, 24 Jun 2026 19:03:28 -0400 Subject: [PATCH 1/2] Add regression test for GetData timeout parsing (#9) Issue #9 reported that a GetData timeout ("result= (timeout)") raised AGINoResultError. It was fixed in 12c4bd7 (2014) by making the value group optional in the KV regex, but the migrated issue was never closed and the behavior was untested. Add regression tests pinning it: the empty-value-with-data parse, and GetData.process_response returning ("", True) on timeout and ("", False) otherwise. Closes #9 --- tests/test_agi_core.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_agi_core.py b/tests/test_agi_core.py index e7c3403..d77a6c8 100644 --- a/tests/test_agi_core.py +++ b/tests/test_agi_core.py @@ -13,6 +13,7 @@ _Action, quote, ) +from pystrix.agi.core import GetData class _FakeReader: @@ -160,3 +161,26 @@ def readline(self): with pytest.raises(UnicodeDecodeError): _agi_with_reader(_BadBytesReader())._get_result() + + +def test_getdata_timeout_result_parses_without_error(): + # Regression for #9 (fixed in 12c4bd7, 2014): a GetData timeout replies + # "result= (timeout)" with an empty value before the parenthetical. It must + # parse as value '' / data 'timeout', not raise AGINoResultError. + response = _agi("200 result= (timeout)\n")._get_result() + assert response.items["result"].value == "" + assert response.items["result"].data == "timeout" + + +def test_getdata_process_response_flags_timeout(): + response = _agi("200 result= (timeout)\n")._get_result() + keys, timed_out = GetData("prompt").process_response(response) + assert keys == "" + assert timed_out is True + + +def test_getdata_process_response_returns_digits(): + response = _agi("200 result=1234\n")._get_result() + keys, timed_out = GetData("prompt").process_response(response) + assert keys == "1234" + assert timed_out is False From 8c5ffa9bbbe556c0b12ea2c2b2f79e0cbb521e3c Mon Sep 17 00:00:00 2001 From: Karthic Raghupathi Date: Wed, 24 Jun 2026 19:16:52 -0400 Subject: [PATCH 2/2] Add partial-digits timeout regression test (#9) Cover the common real-world GetData timeout where a caller enters some digits before the inter-digit timer expires. Asterisk replies "result=12 (timeout)", and process_response must return both the collected digits and the timeout flag. Pins the value/data split that the existing empty-value and no-timeout cases do not exercise together. Co-Authored-By: Claude Opus 4.8 --- tests/test_agi_core.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_agi_core.py b/tests/test_agi_core.py index d77a6c8..41f6655 100644 --- a/tests/test_agi_core.py +++ b/tests/test_agi_core.py @@ -184,3 +184,13 @@ def test_getdata_process_response_returns_digits(): keys, timed_out = GetData("prompt").process_response(response) assert keys == "1234" assert timed_out is False + + +def test_getdata_process_response_keeps_partial_digits_on_timeout(): + # The common real-world timeout: a caller enters some digits, then the + # inter-digit timer expires. Asterisk replies "result=12 (timeout)", so the + # collected digits and the timeout flag must both survive process_response. + response = _agi("200 result=12 (timeout)\n")._get_result() + keys, timed_out = GetData("prompt").process_response(response) + assert keys == "12" + assert timed_out is True