debian-forge/test/run/test_noop.py
Christian Kellner 5b2783be53 test/noop: add format version 2 noop test
Add a simple noop pipeline, with a noop stage and a noop input,
which all in all does nothing much; but it will validate, load
exectue the pipeline, stage and inputs. So maybe not really
"nothing" in the strictest sense.
2021-02-12 15:55:43 +01:00

62 lines
1.6 KiB
Python

#
# Runtime Tests for No-op Pipelines
#
import json
import unittest
import tempfile
from .. import test
NOOP_V2 = {
"version": "2",
"pipelines": [
{
"name": "noop",
"stages": [
{
"type": "org.osbuild.noop",
"options": {"zero": 0},
"inputs": {
"tree": {
"type": "org.osbuild.noop",
"origin": "org.osbuild.pipeline",
"references": {
"foo": {}
}
}
}
}
]
}
]
}
class TestNoop(unittest.TestCase):
def setUp(self):
self.osbuild = test.OSBuild(self)
def test_noop(self):
#
# Run a noop Pipeline. Run twice to verify the cache does not affect
# the operation (we do not have checkpoints, nor any stages that could
# be checkpointed).
#
# Then run the entire thing again, to verify our own `osbuild` executor
# tears things down properly and allows to be executed multiple times.
#
with self.osbuild as osb:
osb.compile("{}")
osb.compile("{}")
with self.osbuild as osb:
osb.compile("{}")
osb.compile("{}")
def test_noop_v2(self):
with tempfile.TemporaryDirectory() as tmp:
with self.osbuild as osb:
osb.compile(json.dumps(NOOP_V2), output_dir=tmp)