lando-client 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lando_client-0.1.0/.gitignore +62 -0
- lando_client-0.1.0/PKG-INFO +10 -0
- lando_client-0.1.0/VERSION +1 -0
- lando_client-0.1.0/lando_client/__init__.py +17 -0
- lando_client-0.1.0/lando_client/client.py +119 -0
- lando_client-0.1.0/lando_client/config.py +62 -0
- lando_client-0.1.0/pyproject.toml +27 -0
- lando_client-0.1.0/tests/test_client.py +167 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
*model
|
|
2
|
+
*model.zst
|
|
3
|
+
*model.zst.etag
|
|
4
|
+
*data_X
|
|
5
|
+
*data_y
|
|
6
|
+
*data_X.zst
|
|
7
|
+
*data_X.zst.etag
|
|
8
|
+
*data_y.zst
|
|
9
|
+
*data_y.zst.etag
|
|
10
|
+
feature_importance.png
|
|
11
|
+
importance.html
|
|
12
|
+
importances.json
|
|
13
|
+
metrics.json
|
|
14
|
+
probs.json
|
|
15
|
+
services/bugbug-api/models/*model*
|
|
16
|
+
|
|
17
|
+
data/
|
|
18
|
+
sheets/
|
|
19
|
+
|
|
20
|
+
.mypy_cache/
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
*.pyc
|
|
23
|
+
.coverage
|
|
24
|
+
|
|
25
|
+
# Distribution / packaging
|
|
26
|
+
.Python
|
|
27
|
+
build/
|
|
28
|
+
develop-eggs/
|
|
29
|
+
dist/
|
|
30
|
+
downloads/
|
|
31
|
+
eggs/
|
|
32
|
+
.eggs/
|
|
33
|
+
lib/
|
|
34
|
+
lib64/
|
|
35
|
+
parts/
|
|
36
|
+
sdist/
|
|
37
|
+
var/
|
|
38
|
+
wheels/
|
|
39
|
+
pip-wheel-metadata/
|
|
40
|
+
share/python-wheels/
|
|
41
|
+
*.egg-info/
|
|
42
|
+
.installed.cfg
|
|
43
|
+
*.egg
|
|
44
|
+
MANIFEST
|
|
45
|
+
cache/
|
|
46
|
+
node_modules/
|
|
47
|
+
|
|
48
|
+
# Logs
|
|
49
|
+
*.log
|
|
50
|
+
# Desktop Service Store
|
|
51
|
+
*.DS_Store
|
|
52
|
+
|
|
53
|
+
# Local env files
|
|
54
|
+
.env
|
|
55
|
+
/services/bugbug-api/docker-compose.override.yml
|
|
56
|
+
|
|
57
|
+
# Local files
|
|
58
|
+
*.local.*
|
|
59
|
+
|
|
60
|
+
# Claude Code local state
|
|
61
|
+
.claude/worktrees/
|
|
62
|
+
.claude/.cc-writes/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: lando-client
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Small shared Lando API client (httpx-based)
|
|
5
|
+
Requires-Python: >=3.14
|
|
6
|
+
Requires-Dist: httpx>=0.26.0
|
|
7
|
+
Requires-Dist: pydantic-settings>=2.1.0
|
|
8
|
+
Provides-Extra: dev
|
|
9
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
10
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from lando_client.client import (
|
|
2
|
+
PATCH_FORMAT_GIT,
|
|
3
|
+
PATCH_FORMAT_HG,
|
|
4
|
+
LandoAPIError,
|
|
5
|
+
LandoClient,
|
|
6
|
+
encode_patch,
|
|
7
|
+
)
|
|
8
|
+
from lando_client.config import LandoSettings
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"LandoAPIError",
|
|
12
|
+
"LandoClient",
|
|
13
|
+
"LandoSettings",
|
|
14
|
+
"PATCH_FORMAT_GIT",
|
|
15
|
+
"PATCH_FORMAT_HG",
|
|
16
|
+
"encode_patch",
|
|
17
|
+
]
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""Small shared Lando API client."""
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from lando_client.config import LandoSettings
|
|
8
|
+
|
|
9
|
+
TREEHERDER_URL = "https://treeherder.mozilla.org"
|
|
10
|
+
|
|
11
|
+
# The patch formats Lando accepts (`PatchFormat` in lando.main.scm.helpers).
|
|
12
|
+
PATCH_FORMAT_GIT = "git-format-patch"
|
|
13
|
+
PATCH_FORMAT_HG = "hgexport"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class LandoAPIError(Exception):
|
|
17
|
+
"""Lando rejected a request (or answered with something unusable)."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def encode_patch(patch: bytes) -> str:
|
|
21
|
+
"""Base64-encode one patch for the ``patches`` array."""
|
|
22
|
+
return base64.b64encode(patch).decode("ascii")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class LandoClient:
|
|
26
|
+
def __init__(self, settings: LandoSettings | None = None) -> None:
|
|
27
|
+
self.settings = settings or LandoSettings.from_env()
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def base_url(self) -> str:
|
|
31
|
+
return self.settings.url.rstrip("/")
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def try_patches_url(self) -> str:
|
|
35
|
+
return f"{self.base_url}/api/try/patches"
|
|
36
|
+
|
|
37
|
+
def job_url(self, job_id: int) -> str:
|
|
38
|
+
"""Lando's own page for a landing job (its live status)."""
|
|
39
|
+
return f"{self.base_url}/landings/{job_id}"
|
|
40
|
+
|
|
41
|
+
def treeherder_url(self, job_id: int, repo_name: str = "try") -> str:
|
|
42
|
+
"""Treeherder's view of a Lando try job.
|
|
43
|
+
|
|
44
|
+
Keyed by ``landoCommitID`` rather than a revision because the push has
|
|
45
|
+
no revision yet: Lando applies the patches asynchronously, so this URL
|
|
46
|
+
is valid (if initially empty) the moment the job is created.
|
|
47
|
+
"""
|
|
48
|
+
return (
|
|
49
|
+
f"{TREEHERDER_URL}/jobs?repo={repo_name}"
|
|
50
|
+
f"&landoInstance={self.settings.instance_id}"
|
|
51
|
+
f"&landoCommitID={job_id}"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
async def submit_try_patches(
|
|
55
|
+
self,
|
|
56
|
+
patches: list[str],
|
|
57
|
+
base_commit: str,
|
|
58
|
+
*,
|
|
59
|
+
base_commit_vcs: str = "git",
|
|
60
|
+
patch_format: str = PATCH_FORMAT_GIT,
|
|
61
|
+
repo_name: str = "try",
|
|
62
|
+
) -> int:
|
|
63
|
+
"""Submit a base64-encoded patch series to a Try repo; return the job id.
|
|
64
|
+
|
|
65
|
+
``patches`` are applied in order on top of ``base_commit``, which must be
|
|
66
|
+
a full 40-character hash of a *published* commit (Lando maps it to the
|
|
67
|
+
try repo's own SCM when ``base_commit_vcs`` differs, so a firefox git
|
|
68
|
+
sha is fine for the Mercurial ``try``).
|
|
69
|
+
"""
|
|
70
|
+
payload = {
|
|
71
|
+
"repo_name": repo_name,
|
|
72
|
+
"base_commit": base_commit,
|
|
73
|
+
"base_commit_vcs": base_commit_vcs,
|
|
74
|
+
"patch_format": patch_format,
|
|
75
|
+
"patches": patches,
|
|
76
|
+
}
|
|
77
|
+
async with httpx.AsyncClient(timeout=self.settings.timeout_seconds) as client:
|
|
78
|
+
response = await client.post(
|
|
79
|
+
self.try_patches_url,
|
|
80
|
+
json=payload,
|
|
81
|
+
headers={
|
|
82
|
+
"Authorization": f"Bearer {self.settings.access_token}",
|
|
83
|
+
"User-Agent": self.settings.user_agent,
|
|
84
|
+
},
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if response.status_code >= 400:
|
|
88
|
+
raise LandoAPIError(_error_detail(response))
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
return int(response.json()["id"])
|
|
92
|
+
except (ValueError, KeyError, TypeError) as exc:
|
|
93
|
+
raise LandoAPIError(
|
|
94
|
+
f"Lando accepted the push ({response.status_code}) but returned no "
|
|
95
|
+
"job id"
|
|
96
|
+
) from exc
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _error_detail(response: httpx.Response) -> str:
|
|
100
|
+
"""A readable message for a failed Lando response.
|
|
101
|
+
|
|
102
|
+
Lando reports errors as RFC 7807 problem details (``title``/``detail``),
|
|
103
|
+
but a proxy or a 5xx can still answer with HTML, so fall back to the status
|
|
104
|
+
line rather than raising a ``JSONDecodeError`` over the real failure.
|
|
105
|
+
"""
|
|
106
|
+
try:
|
|
107
|
+
problem = response.json()
|
|
108
|
+
except ValueError:
|
|
109
|
+
problem = None
|
|
110
|
+
|
|
111
|
+
if isinstance(problem, dict):
|
|
112
|
+
parts = [str(problem[key]) for key in ("title", "detail") if problem.get(key)]
|
|
113
|
+
if parts:
|
|
114
|
+
return f"Lando returned HTTP {response.status_code}: {': '.join(parts)}"
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
f"Lando returned HTTP {response.status_code} ({response.reason_phrase}) "
|
|
118
|
+
f"for {response.request.url}"
|
|
119
|
+
)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Configuration for :class:`LandoClient`."""
|
|
2
|
+
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
from urllib.parse import urlsplit
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field, model_validator
|
|
7
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
8
|
+
|
|
9
|
+
# Lando deployment names, keyed by the host they serve. This pairing is not
|
|
10
|
+
# something Lando exposes over its API: `instance_id` is a *client-side* label,
|
|
11
|
+
# declared in mozilla-central's `.lando.ini` (one `instance_id`/`api_domain`
|
|
12
|
+
# pair per section) and mapped back to a host by Treeherder itself.
|
|
13
|
+
INSTANCE_IDS_BY_HOST = {
|
|
14
|
+
"lando.moz.tools": "lando-prod-2025",
|
|
15
|
+
"lando-dev.allizom.org": "lando-dev-2025",
|
|
16
|
+
"api.lando.services.mozilla.com": "lando-prod",
|
|
17
|
+
"api.dev.lando.nonprod.cloudops.mozgcp.net": "lando-dev",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class LandoSettings(BaseModel):
|
|
22
|
+
"""Where Lando lives and how to authenticate against it.
|
|
23
|
+
|
|
24
|
+
``access_token`` is an OIDC bearer token for the account that owns the
|
|
25
|
+
pushes: Lando's Try endpoint authenticates the *user* (it has no API-key
|
|
26
|
+
mode), and the try repository's permissions are checked against that user.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
access_token: Annotated[str, Field(min_length=1)]
|
|
30
|
+
url: str = "https://lando.moz.tools"
|
|
31
|
+
instance_id: str | None = None
|
|
32
|
+
timeout_seconds: int = 60
|
|
33
|
+
user_agent: str = "Lando-User/Hackbot"
|
|
34
|
+
|
|
35
|
+
@model_validator(mode="after")
|
|
36
|
+
def _resolve_instance_id(self) -> LandoSettings:
|
|
37
|
+
host = urlsplit(self.url).hostname
|
|
38
|
+
resolved = INSTANCE_IDS_BY_HOST.get(host)
|
|
39
|
+
if not resolved and not self.instance_id:
|
|
40
|
+
known_hosts = ", ".join(sorted(INSTANCE_IDS_BY_HOST))
|
|
41
|
+
raise ValueError(
|
|
42
|
+
f"Unknown Lando host {host!r}: cannot tell which deployment "
|
|
43
|
+
"Treeherder should link to. Set LANDO_INSTANCE_ID explicitly "
|
|
44
|
+
f"(known hosts: {known_hosts})."
|
|
45
|
+
)
|
|
46
|
+
if resolved and self.instance_id and self.instance_id != resolved:
|
|
47
|
+
raise ValueError(
|
|
48
|
+
f"LANDO_INSTANCE_ID {self.instance_id!r} does not match the "
|
|
49
|
+
f"known deployment for {host!r} ({resolved!r})."
|
|
50
|
+
)
|
|
51
|
+
if resolved and not self.instance_id:
|
|
52
|
+
self.instance_id = resolved
|
|
53
|
+
|
|
54
|
+
return self
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_env(cls) -> LandoSettings:
|
|
58
|
+
return _LandoEnvSettings()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class _LandoEnvSettings(LandoSettings, BaseSettings):
|
|
62
|
+
model_config = SettingsConfigDict(env_prefix="LANDO_", extra="ignore")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "lando-client"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Small shared Lando API client (httpx-based)"
|
|
5
|
+
requires-python = ">=3.14"
|
|
6
|
+
dependencies = [
|
|
7
|
+
"httpx>=0.26.0",
|
|
8
|
+
"pydantic-settings>=2.1.0",
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
[project.optional-dependencies]
|
|
12
|
+
dev = ["pytest>=8.0.0", "pytest-asyncio>=0.23.0"]
|
|
13
|
+
|
|
14
|
+
[build-system]
|
|
15
|
+
requires = ["hatchling"]
|
|
16
|
+
build-backend = "hatchling.build"
|
|
17
|
+
|
|
18
|
+
[tool.hatch.version]
|
|
19
|
+
path = "VERSION"
|
|
20
|
+
pattern = "(?P<version>.+)"
|
|
21
|
+
|
|
22
|
+
[tool.hatch.build.targets.wheel]
|
|
23
|
+
packages = ["lando_client"]
|
|
24
|
+
|
|
25
|
+
[tool.pytest.ini_options]
|
|
26
|
+
asyncio_mode = "auto"
|
|
27
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""Tests for the shared Lando client."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from base64 import b64decode
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
import pytest
|
|
8
|
+
from lando_client import (
|
|
9
|
+
LandoAPIError,
|
|
10
|
+
LandoClient,
|
|
11
|
+
LandoSettings,
|
|
12
|
+
encode_patch,
|
|
13
|
+
)
|
|
14
|
+
from lando_client import client as client_module
|
|
15
|
+
from pydantic import ValidationError
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _client(**kwargs) -> LandoClient:
|
|
19
|
+
return LandoClient(LandoSettings(access_token="token", **kwargs))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _capture_post(monkeypatch, response: httpx.Response) -> dict:
|
|
23
|
+
"""Stub httpx.AsyncClient to answer with `response`; capture the call."""
|
|
24
|
+
captured: dict = {}
|
|
25
|
+
|
|
26
|
+
class _FakeAsyncClient:
|
|
27
|
+
def __init__(self, timeout=None):
|
|
28
|
+
captured["timeout"] = timeout
|
|
29
|
+
|
|
30
|
+
async def __aenter__(self):
|
|
31
|
+
return self
|
|
32
|
+
|
|
33
|
+
async def __aexit__(self, *exc):
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
async def post(self, url, json=None, headers=None):
|
|
37
|
+
captured["url"] = url
|
|
38
|
+
captured["json"] = json
|
|
39
|
+
captured["headers"] = headers
|
|
40
|
+
response.request = httpx.Request("POST", url)
|
|
41
|
+
return response
|
|
42
|
+
|
|
43
|
+
monkeypatch.setattr(client_module.httpx, "AsyncClient", _FakeAsyncClient)
|
|
44
|
+
return captured
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_access_token_is_required():
|
|
48
|
+
with pytest.raises(ValidationError):
|
|
49
|
+
LandoSettings(access_token="")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_urls_are_built_from_the_configured_host():
|
|
53
|
+
client = _client(url="https://lando-dev.allizom.org/")
|
|
54
|
+
|
|
55
|
+
# A trailing slash in config must not double up in the URLs.
|
|
56
|
+
assert client.try_patches_url == "https://lando-dev.allizom.org/api/try/patches"
|
|
57
|
+
assert client.job_url(7) == "https://lando-dev.allizom.org/landings/7"
|
|
58
|
+
# Pointing at another deployment moves the Treeherder link with it, with no
|
|
59
|
+
# second setting to keep in step.
|
|
60
|
+
assert client.treeherder_url(7) == (
|
|
61
|
+
"https://treeherder.mozilla.org/jobs?repo=try"
|
|
62
|
+
"&landoInstance=lando-dev-2025&landoCommitID=7"
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@pytest.mark.parametrize(
|
|
67
|
+
("url", "expected"),
|
|
68
|
+
[
|
|
69
|
+
("https://lando.moz.tools", "lando-prod-2025"),
|
|
70
|
+
("https://lando-dev.allizom.org", "lando-dev-2025"),
|
|
71
|
+
("https://api.lando.services.mozilla.com", "lando-prod"),
|
|
72
|
+
("https://api.dev.lando.nonprod.cloudops.mozgcp.net", "lando-dev"),
|
|
73
|
+
],
|
|
74
|
+
)
|
|
75
|
+
def test_instance_id_is_derived_from_the_host(url, expected):
|
|
76
|
+
"""Matches Treeherder's own instance -> host map (ui/helpers/url.js)."""
|
|
77
|
+
assert _client(url=url).settings.instance_id == expected
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_instance_id_defaults_to_prod_without_any_configuration():
|
|
81
|
+
assert LandoSettings(access_token="t").instance_id == "lando-prod-2025"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_explicit_instance_id_wins_for_an_unknown_host():
|
|
85
|
+
settings = LandoSettings(
|
|
86
|
+
access_token="t", url="https://lando.example.test", instance_id="lando-local"
|
|
87
|
+
)
|
|
88
|
+
assert settings.instance_id == "lando-local"
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_unknown_host_without_an_instance_id_is_rejected():
|
|
92
|
+
"""A wrong id points Treeherder at the wrong Lando, so never guess one."""
|
|
93
|
+
with pytest.raises(ValidationError, match="Unknown Lando host"):
|
|
94
|
+
LandoSettings(access_token="t", url="https://lando.example.test")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def test_treeherder_url_follows_the_repo():
|
|
98
|
+
assert "repo=try-comm-central" in _client().treeherder_url(7, "try-comm-central")
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def test_encode_patch_is_plain_base64():
|
|
102
|
+
# Lando's schema rejects anything but `^[A-Za-z0-9+/]+={0,2}$`, so a long
|
|
103
|
+
# patch must not come back wrapped across lines.
|
|
104
|
+
patch = b"From abc\nSubject: [PATCH] a fix\n" * 50
|
|
105
|
+
encoded = encode_patch(patch)
|
|
106
|
+
|
|
107
|
+
assert re.fullmatch(r"[A-Za-z0-9+/]+={0,2}", encoded)
|
|
108
|
+
assert b64decode(encoded) == patch
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
async def test_submit_try_patches_posts_the_series_and_returns_the_job_id(monkeypatch):
|
|
112
|
+
captured = _capture_post(monkeypatch, httpx.Response(201, json={"id": 4321}))
|
|
113
|
+
|
|
114
|
+
job_id = await _client().submit_try_patches(["cGF0Y2g="], "a" * 40)
|
|
115
|
+
|
|
116
|
+
assert job_id == 4321
|
|
117
|
+
assert captured["url"] == "https://lando.moz.tools/api/try/patches"
|
|
118
|
+
assert captured["headers"]["Authorization"] == "Bearer token"
|
|
119
|
+
assert captured["json"] == {
|
|
120
|
+
"repo_name": "try",
|
|
121
|
+
"base_commit": "a" * 40,
|
|
122
|
+
"base_commit_vcs": "git",
|
|
123
|
+
"patch_format": "git-format-patch",
|
|
124
|
+
"patches": ["cGF0Y2g="],
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
async def test_submit_try_patches_raises_with_lando_problem_detail(monkeypatch):
|
|
129
|
+
_capture_post(
|
|
130
|
+
monkeypatch,
|
|
131
|
+
httpx.Response(
|
|
132
|
+
400,
|
|
133
|
+
json={
|
|
134
|
+
"title": "Not a Try repository",
|
|
135
|
+
"detail": "Repo autoland is not a Try repository.",
|
|
136
|
+
"status": 400,
|
|
137
|
+
"type": "about:blank",
|
|
138
|
+
},
|
|
139
|
+
),
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
with pytest.raises(LandoAPIError) as excinfo:
|
|
143
|
+
await _client().submit_try_patches(["cGF0Y2g="], "a" * 40)
|
|
144
|
+
|
|
145
|
+
assert "Not a Try repository" in str(excinfo.value)
|
|
146
|
+
assert "Repo autoland is not a Try repository." in str(excinfo.value)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
async def test_submit_try_patches_raises_on_a_non_json_error(monkeypatch):
|
|
150
|
+
"""A 5xx from a proxy answers with HTML, not a problem detail."""
|
|
151
|
+
_capture_post(
|
|
152
|
+
monkeypatch, httpx.Response(503, text="<html>Service Unavailable</html>")
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
with pytest.raises(LandoAPIError) as excinfo:
|
|
156
|
+
await _client().submit_try_patches(["cGF0Y2g="], "a" * 40)
|
|
157
|
+
|
|
158
|
+
assert "HTTP 503" in str(excinfo.value)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
async def test_submit_try_patches_raises_when_no_job_id_comes_back(monkeypatch):
|
|
162
|
+
_capture_post(monkeypatch, httpx.Response(201, json={}))
|
|
163
|
+
|
|
164
|
+
with pytest.raises(LandoAPIError) as excinfo:
|
|
165
|
+
await _client().submit_try_patches(["cGF0Y2g="], "a" * 40)
|
|
166
|
+
|
|
167
|
+
assert "no job id" in str(excinfo.value)
|