Initial curated Unraid-AppOps-Gateway source from 3bd6f6fee310125bfbb4d4650389a817f498724d
This commit is contained in:
commit
1dfbca08a1
528 files changed
+131054
No files matched your search
@@ -0,0 +1,41 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
from backend.app.connectors.portainer import PortainerConnector
|
||||
from backend.app.core.config import settings
|
||||
|
||||
|
||||
def test_restart_request_allows_docker_grace_period_without_shortening_container_timeout(monkeypatch):
|
||||
previous = dict(settings.apis)
|
||||
settings.apis.update({
|
||||
"PORTAINER_URL": "https://portainer.example.test",
|
||||
"PORTAINER_API_KEY": "test-key",
|
||||
"PORTAINER_ENDPOINT_ID": "9",
|
||||
})
|
||||
connector = PortainerConnector()
|
||||
monkeypatch.setattr(
|
||||
connector,
|
||||
"list_containers",
|
||||
lambda: {
|
||||
"status": "ok",
|
||||
"containers": [{"id": "runner-id", "name": "itworx-validation-runner-2", "appId": "itworx-validation-runner-2"}],
|
||||
},
|
||||
)
|
||||
calls: list[tuple[str, str, dict]] = []
|
||||
|
||||
def request(method: str, path: str, **kwargs):
|
||||
calls.append((method, path, kwargs))
|
||||
return SimpleNamespace(status_code=204)
|
||||
|
||||
monkeypatch.setattr(connector, "_request", request)
|
||||
try:
|
||||
result = connector.restart_container("itworx-validation-runner-2")
|
||||
finally:
|
||||
settings.apis.clear()
|
||||
settings.apis.update(previous)
|
||||
|
||||
assert result["status"] == "ok"
|
||||
assert calls == [(
|
||||
"POST",
|
||||
"/api/endpoints/9/docker/containers/runner-id/restart",
|
||||
{"timeout": 30.0},
|
||||
)]
|
||||
Reference in new issue
Block a user