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:
@@ -3,14 +3,14 @@ import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import unittest.mock
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from atlassian import client
|
||||
from rest_client.json_request import ErrorAnswer
|
||||
from failure import Failure
|
||||
from rest_client.test_json_request import Served
|
||||
|
||||
SEARCH = "https://acme.atlassian.net/rest/api/3/search/jql"
|
||||
AUTHORIZATION = "Basic " + base64.b64encode(b"me@example.com:s3cret").decode()
|
||||
|
||||
|
||||
@@ -26,11 +26,12 @@ class Credentials(unittest.TestCase):
|
||||
self.assertIsInstance(client.basic_auth(pathlib.Path("/nonexistent/acme.env")), Failure)
|
||||
|
||||
|
||||
class Jira(unittest.TestCase):
|
||||
def test_sends_each_request_through_the_shared_client_with_jiras_error_messages(self):
|
||||
with unittest.mock.patch.object(client.json_request, "http_json", return_value={"issues": []}) as sent:
|
||||
self.assertEqual(client.jira_json("POST", SEARCH, AUTHORIZATION, {"jql": "x"}), {"issues": []})
|
||||
sent.assert_called_once_with("POST", SEARCH, AUTHORIZATION, {"jql": "x"}, 30, client.jira_errors)
|
||||
class Jira(Served):
|
||||
def test_an_error_answer_fails_with_jiras_messages_and_its_status(self):
|
||||
base = self.serve((400, b'{"errorMessages": ["One."], "errors": {"jql": "Two."}}'))
|
||||
self.assertEqual(client.jira_json("POST", f"{base}/rest/api/3/search/jql", AUTHORIZATION, {"jql": "x"}), ErrorAnswer("POST /rest/api/3/search/jql answered 400: One.; Two.", 400))
|
||||
[(_, _, headers, _)] = self.server.got # type: ignore[attr-defined]
|
||||
self.assertEqual(headers["Authorization"], AUTHORIZATION)
|
||||
|
||||
def test_reads_jiras_messages_from_an_error_answer(self):
|
||||
cases = (
|
||||
@@ -45,11 +46,10 @@ class Jira(unittest.TestCase):
|
||||
self.assertEqual(client.jira_errors(answer), message)
|
||||
|
||||
|
||||
class Confluence(unittest.TestCase):
|
||||
def test_sends_each_request_through_the_shared_client_with_confluences_error_messages(self):
|
||||
with unittest.mock.patch.object(client.json_request, "http_json", return_value={}) as sent:
|
||||
self.assertEqual(client.confluence_json("GET", "https://acme.atlassian.net/wiki/api/v2/pages/1", AUTHORIZATION, None), {})
|
||||
sent.assert_called_once_with("GET", "https://acme.atlassian.net/wiki/api/v2/pages/1", AUTHORIZATION, None, 30, client.confluence_errors)
|
||||
class Confluence(Served):
|
||||
def test_an_error_answer_fails_with_confluences_messages_and_its_status(self):
|
||||
base = self.serve((409, b'{"errors": [{"status": 409, "title": "Version must be incremented"}]}'))
|
||||
self.assertEqual(client.confluence_json("PUT", f"{base}/wiki/api/v2/pages/1", AUTHORIZATION, {}), ErrorAnswer("PUT /wiki/api/v2/pages/1 answered 409: Version must be incremented", 409))
|
||||
|
||||
def test_reads_confluences_messages_from_an_error_answer(self):
|
||||
self.assertEqual(client.confluence_errors({"errors": [{"status": 409, "title": "Version must be incremented"}, {"title": "and more"}, "odd"]}), "Version must be incremented; and more")
|
||||
|
||||
Reference in New Issue
Block a user