Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s
CI / tests (pull_request) Successful in 3m43s
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
"""Sends a direct message from a Mattermost bot to one user, through Mattermost's REST API v4. The `notifier` setting `mattermost` picks it."""
|
||||
import dataclasses
|
||||
import pathlib
|
||||
import typing
|
||||
import urllib.parse
|
||||
|
||||
from failure import Failure
|
||||
from rest_client.json_request import Http
|
||||
from rest_client.json_request import Http, MessageOf
|
||||
from rest_client import json_request
|
||||
from rest_client.env_file import read_env
|
||||
|
||||
@@ -53,9 +54,10 @@ def id_of(answer: object, request: str) -> str | Failure:
|
||||
return found if isinstance(found, str) and found else Failure(f"{request} answered without an id")
|
||||
|
||||
|
||||
def http_json(method: str, url: str, token: str, body: object) -> object:
|
||||
# request is json_request.http_json, but in the test of what this hands it.
|
||||
def http_json(method: str, url: str, token: str, body: object, request: typing.Callable[[str, str, str, object, int, MessageOf], object] = json_request.http_json) -> object:
|
||||
"""The JSON that url answers to the bot's request, None where the answer has no body, or a Failure saying why there is none."""
|
||||
return json_request.http_json(method, url, f"Bearer {token}", body, TIMEOUT, error_message)
|
||||
return request(method, url, f"Bearer {token}", body, TIMEOUT, error_message)
|
||||
|
||||
|
||||
def error_message(answer: object) -> str:
|
||||
|
||||
Reference in New Issue
Block a user