From f4411cf679b8ec7557233490601f3c1875a32113 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 9 Nov 2026 18:18:29 +0100 Subject: feat: sb-builder status module --- tests/test_sbbuilder.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/test_sbbuilder.py (limited to 'tests') diff --git a/tests/test_sbbuilder.py b/tests/test_sbbuilder.py new file mode 100644 index 0000000..5c5438e --- /dev/null +++ b/tests/test_sbbuilder.py @@ -0,0 +1,29 @@ +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) + +import json +import unittest + +import deckit.modules.sbbuilder as sbb + + +class Fail(unittest.TestCase): + def test_offline_on_ssh_failure(self): + def boom(cmd, timeout=5): + raise OSError("no route") + self.assertTrue(sbb.make({"sbbuilder": {"host": "buildsystem"}, "run": boom}).state()["offline"]) + + +class Ok(unittest.TestCase): + def test_parses_jobs(self): + out = json.dumps({"jobs": [{"id": "20261109-101010-build", "status": "running"}]}) + st = sbb.make({"sbbuilder": {"host": "buildsystem"}, + "run": lambda cmd, timeout=5: out}).state() + self.assertFalse(st["offline"]) + self.assertEqual(st["jobs"][0]["status"], "running") + + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3