From 8cfb2406b0ad42ad8ede7d6db50c5797f1f0a1c8 Mon Sep 17 00:00:00 2001 From: Maciej Borzecki Date: Wed, 7 Feb 2024 13:54:45 +0100 Subject: [PATCH] subiquitycore: allow to register callbacks for POST for fake snapd connections Allow registration of handlers for POST. Signed-off-by: Maciej Borzecki --- subiquitycore/snapd.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subiquitycore/snapd.py b/subiquitycore/snapd.py index 108e8d37..fa95223f 100644 --- a/subiquitycore/snapd.py +++ b/subiquitycore/snapd.py @@ -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)) )