subiquitycore: allow to register callbacks for POST for fake snapd connections

Allow registration of handlers for POST.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
This commit is contained in:
Maciej Borzecki 2024-02-07 13:54:45 +01:00
parent f0183d1cee
commit 8cfb2406b0
1 changed files with 4 additions and 0 deletions

View File

@ -127,6 +127,7 @@ class FakeSnapdConnection:
self.scale_factor = scale_factor
self.response_sets = {}
self.output_base = output_base
self.post_cb = {}
def configure_proxy(self, proxy):
log.debug("pretending to restart snapd to pick up proxy config")
@ -167,6 +168,9 @@ class FakeSnapdConnection:
"status": "Accepted",
}
)
if path in self.post_cb:
return _FakeMemoryResponse(self.post_cb[path](path, body, **args))
raise Exception(
"Don't know how to fake POST response to {}".format((path, args))
)