From ea86499691aa58d21cbd68709dc81ce171651d68 Mon Sep 17 00:00:00 2001 From: Maciej Borzecki Date: Wed, 7 Feb 2024 15:43:22 +0100 Subject: [PATCH] subiquitycore/snapd: add response set serving objects from memory Signed-off-by: Maciej Borzecki --- subiquitycore/snapd.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/subiquitycore/snapd.py b/subiquitycore/snapd.py index fa95223f..97bba5b2 100644 --- a/subiquitycore/snapd.py +++ b/subiquitycore/snapd.py @@ -121,6 +121,19 @@ class ResponseSet: return _FakeFileResponse(f) +class MemoryResponseSet: + """Set of response for an endpoint which returns data stored in memory.""" + + def __init__(self, data): + self.data = data + self.index = 0 + + def next(self): + d = self.data[self.index] + self.index += 1 + return _FakeMemoryResponse(d) + + class FakeSnapdConnection: def __init__(self, snap_data_dir, scale_factor, output_base): self.snap_data_dir = snap_data_dir