Answer principles round 1: 2 🔴, 9 🟡 (0 misread); explicit record versions in place of the Confluence store's hidden state, the routing ruling filed as item 393 for 0.12.0, rule-hook catching heavy runs through uv, poetry, sudo and doas, one unreleased heading, one owner of the no-item message, typed Jira issues, a turn that gives its failure as a value, outcome tests for the Atlassian client, an Emptied reason type, an injected clock and git in touch-predictions, and paired record names
This commit is contained in:
@@ -30,6 +30,9 @@ class Recorded(http.server.BaseHTTPRequestHandler):
|
||||
def do_POST(self) -> None:
|
||||
self.answer()
|
||||
|
||||
def do_PUT(self) -> None:
|
||||
self.answer()
|
||||
|
||||
def answer(self) -> None:
|
||||
length = int(self.headers.get("Content-Length") or 0)
|
||||
self.server.got.append((self.command, self.path, dict(self.headers), self.rfile.read(length))) # type: ignore[attr-defined]
|
||||
@@ -50,7 +53,9 @@ class Recorded(http.server.BaseHTTPRequestHandler):
|
||||
pass
|
||||
|
||||
|
||||
class HttpJson(unittest.TestCase):
|
||||
class Served(unittest.TestCase):
|
||||
"""A test case with a local server that answers by a script; it holds no test itself, so a test elsewhere may build on it."""
|
||||
|
||||
def serve(self, *script: tuple[int, bytes]) -> str:
|
||||
server = http.server.HTTPServer(("127.0.0.1", 0), Recorded)
|
||||
server.script = list(script) # type: ignore[attr-defined]
|
||||
@@ -61,6 +66,8 @@ class HttpJson(unittest.TestCase):
|
||||
self.server = server
|
||||
return f"http://127.0.0.1:{server.server_port}"
|
||||
|
||||
|
||||
class HttpJson(Served):
|
||||
def test_sends_the_authorization_and_the_body_as_json_and_reads_the_json_answer(self):
|
||||
base = self.serve((201, b'{"id": "post-id"}'))
|
||||
self.assertEqual(send("POST", f"{base}/api/v4/posts", "secret-token", {"message": "hi"}), {"id": "post-id"})
|
||||
|
||||
Reference in New Issue
Block a user