aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_sbbuilder.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_sbbuilder.py')
-rw-r--r--tests/test_sbbuilder.py29
1 files changed, 29 insertions, 0 deletions
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()