From 44da791f5a3f9066caa9b2a0eded1c44eadab8ad Mon Sep 17 00:00:00 2001 From: Henrik Jess Nielsen Date: Sun, 10 May 2026 13:35:40 +0200 Subject: [PATCH] fix: update tests to match thread-based proxy API (_frame, _inject_completions) BicepProxy class and _ContentLengthFramer no longer exist after rewrite. Tests now call module-level functions directly. --- tests/test_proxy.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/test_proxy.py b/tests/test_proxy.py index 7c0bce5..88253e5 100644 --- a/tests/test_proxy.py +++ b/tests/test_proxy.py @@ -5,12 +5,12 @@ import json import pytest from ilsp.bicep_lsp.modules import BicepModuleCatalog -from ilsp.bicep_lsp.proxy import BicepProxy, _ContentLengthFramer +from ilsp.bicep_lsp.proxy import _frame, _inject_completions def test_frame_produces_correct_header(): body = b'{"jsonrpc":"2.0"}' - framed = _ContentLengthFramer.frame(body) + framed = _frame(body) assert framed.startswith(b"Content-Length: 17\r\n\r\n") assert framed.endswith(body) @@ -21,10 +21,6 @@ def reset_modules(): yield -def _make_proxy() -> BicepProxy: - return BicepProxy.__new__(BicepProxy) - - def _completion_response(items: list) -> dict: return { "jsonrpc": "2.0", @@ -35,9 +31,8 @@ def _completion_response(items: list) -> dict: def test_standard_items_not_downgraded_without_lru(): """Without LRU modules, standard items keep their original sortText.""" - proxy = _make_proxy() msg = _completion_response([{"label": "Microsoft.Storage", "sortText": "az"}]) - out = json.loads(proxy._maybe_inject_completions(msg)) + out = json.loads(_inject_completions(msg)) # No LRU modules → no downgrade, original sortText preserved assert out["result"]["items"][0]["sortText"] == "az" @@ -51,9 +46,8 @@ def test_lru_modules_injected_at_top(): "registry": "iactemplatereg.azurecr.io", }] - proxy = _make_proxy() msg = _completion_response([{"label": "Microsoft.Web/sites", "sortText": "az"}]) - out = json.loads(proxy._maybe_inject_completions(msg)) + out = json.loads(_inject_completions(msg)) items = out["result"]["items"] assert items[0]["label"] == "appservice" @@ -71,15 +65,13 @@ def test_list_result_also_handled(): "registry": "iactemplatereg.azurecr.io", }] - proxy = _make_proxy() msg = {"jsonrpc": "2.0", "id": 2, "result": [{"label": "az-item", "sortText": "az"}]} - out = json.loads(proxy._maybe_inject_completions(msg)) + out = json.loads(_inject_completions(msg)) assert isinstance(out["result"], list) assert out["result"][0]["label"] == "roleassignments" def test_non_completion_message_passthrough(): - proxy = _make_proxy() msg = {"jsonrpc": "2.0", "method": "initialized", "params": {}} - out = json.loads(proxy._maybe_inject_completions(msg)) + out = json.loads(_inject_completions(msg)) assert out["method"] == "initialized"