Skip to content

Commit 5346612

Browse files
authored
Merge pull request #44 from VectorlyApp/remove-bare-placeholders
rm bare token interpolation
2 parents 2414636 + 5d160f0 commit 5346612

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

src/cdp/routine_execution.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,6 @@ def _apply_params(text: str, parameters_dict: dict | None) -> str:
474474
double_escaped = r'\\"' + r'\{\{' + r'\s*' + escaped_key + r'\s*' + r'\}\}' + r'\\"'
475475
text = re.sub(double_escaped, literal, text)
476476

477-
# Pattern 3: Bare placeholder {{key}} (unquoted, for URL params, etc.)
478-
bare_pattern = r'\{\{' + r'\s*' + escaped_key + r'\s*' + r'\}\}'
479-
text = re.sub(bare_pattern, str(value), text)
480477

481478
return text
482479

tests/unit/test_production_routine.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -874,49 +874,6 @@ def test_routine_with_escaped_string_params_from_json(self, input_data_dir: Path
874874
assert "{{search_query}}" in fetch_op.endpoint.url
875875
assert "{{page_size}}" in fetch_op.endpoint.url
876876

877-
def test_yahoo_finance_routine_from_discovery_output(self) -> None:
878-
"""Real-world example: Yahoo Finance routine with escaped string headers."""
879-
# load the actual routine from routine_discovery_output
880-
routine_path = Path("/home/ec2-user/web-hacker/routine_discovery_output/routine.json")
881-
if not routine_path.exists():
882-
pytest.skip("Yahoo Finance routine not found in routine_discovery_output")
883-
884-
data = load_data(routine_path)
885-
routine = Routine(**data)
886-
887-
assert routine.name == "Yahoo Finance - Search Ticker"
888-
assert len(routine.parameters) == 6
889-
890-
# verify all parameters are string or integer types
891-
param_types = {p.name: p.type for p in routine.parameters}
892-
assert param_types["query"] == ParameterType.STRING
893-
assert param_types["lang"] == ParameterType.STRING
894-
assert param_types["region"] == ParameterType.STRING
895-
assert param_types["quotesCount"] == ParameterType.INTEGER
896-
assert param_types["newsCount"] == ParameterType.INTEGER
897-
assert param_types["listsCount"] == ParameterType.INTEGER
898-
899-
# get the fetch operation
900-
fetch_op = routine.operations[2]
901-
assert isinstance(fetch_op, RoutineFetchOperation)
902-
903-
# verify STRING parameters are ESCAPED in x-param headers
904-
assert fetch_op.endpoint.headers["x-param-query"] == '"{{query}}"'
905-
assert fetch_op.endpoint.headers["x-param-lang"] == '"{{lang}}"'
906-
assert fetch_op.endpoint.headers["x-param-region"] == '"{{region}}"'
907-
908-
# verify INTEGER parameters are ESCAPED in x-param headers (note: even integers get escaped in this pattern)
909-
assert fetch_op.endpoint.headers["x-param-quotesCount"] == '"{{quotesCount}}"'
910-
assert fetch_op.endpoint.headers["x-param-newsCount"] == '"{{newsCount}}"'
911-
assert fetch_op.endpoint.headers["x-param-listsCount"] == '"{{listsCount}}"'
912-
913-
# verify parameters are in URL (no escaping in URLs)
914-
assert "{{query}}" in fetch_op.endpoint.url
915-
assert "{{lang}}" in fetch_op.endpoint.url
916-
assert "{{region}}" in fetch_op.endpoint.url
917-
assert "{{quotesCount}}" in fetch_op.endpoint.url
918-
assert "{{newsCount}}" in fetch_op.endpoint.url
919-
assert "{{listsCount}}" in fetch_op.endpoint.url
920877

921878
def test_routine_inherits_from_resource_base(self) -> None:
922879
"""Routine should inherit ResourceBase functionality."""

0 commit comments

Comments
 (0)