feat(infra): auto-commit con 88 cambios

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-11 00:16:46 +02:00
parent 6bc97df5c0
commit eb8dbf66a1
126 changed files with 10933 additions and 287 deletions
@@ -0,0 +1,90 @@
"""Tests para hoppscotch_update_request.
Deterministas: monkeypatchean requests.post para no tocar la red. Verifican que
el POST GraphQL lleva la mutation updateRequest con requestID, el access_token
en la cookie, y que `request` es el json string de un HoppRESTRequest v:"2".
"""
import json
import sys
import infra.hoppscotch_update_request # noqa: F401
# El __init__ rebinds el nombre a la funcion; recuperamos el submodulo real.
mod = sys.modules["infra.hoppscotch_update_request"]
class _FakeResponse:
def __init__(self, status_code=200, json_data=None):
self.status_code = status_code
self._json = json_data
def json(self):
if self._json is None:
raise ValueError("no json")
return self._json
def test_golden_actualiza_request_y_devuelve_id(monkeypatch):
captured = {}
def fake_post(url, **kwargs):
captured["url"] = url
captured["kwargs"] = kwargs
return _FakeResponse(
200,
{
"data": {
"updateRequest": {"id": "req-7", "title": "New title"}
}
},
)
monkeypatch.setattr(mod.requests, "post", fake_post)
result = mod.hoppscotch_update_request(
"req-7",
"POST",
"https://api.example.com/x",
title="New title",
body="a=1&b=2",
body_type="form",
access_token="ACCESS-JWT",
)
assert result["status"] == "ok"
assert result["id"] == "req-7"
assert result["title"] == "New title"
assert captured["url"].endswith("/graphql")
assert captured["kwargs"]["cookies"] == {"access_token": "ACCESS-JWT"}
payload = captured["kwargs"]["json"]
assert "updateRequest" in payload["query"]
variables = payload["variables"]
assert variables["r"] == "req-7"
assert variables["d"]["title"] == "New title"
req = json.loads(variables["d"]["request"])
assert req["v"] == "2"
assert req["method"] == "POST"
assert req["body"] == {
"contentType": "application/x-www-form-urlencoded",
"body": "a=1&b=2",
}
def test_error_graphql_errors(monkeypatch):
def fake_post(url, **kwargs):
return _FakeResponse(
200, {"errors": [{"message": "team_req/not_found"}]}
)
monkeypatch.setattr(mod.requests, "post", fake_post)
result = mod.hoppscotch_update_request(
"missing", "GET", "https://x", access_token="A"
)
assert result["status"] == "error"
assert result["error"] == "graphql errors"
assert "errors" in result["data"]