debian-forge/test/run/test_executable.py
Christian Kellner a47a40cf26 test: remove unittest dependency for OSBuild
Remove the dependency on unittest for the `OSBuild` class which
used the `unittest` instance only for `assertEqual`, which can
easily also be done via a plain `assert`.
2021-06-21 18:56:38 +02:00

30 lines
808 B
Python

#
# Runtime Tests for the `osbuild` executable
#
import json
import subprocess
import unittest
from .. import test
class TestExecutable(unittest.TestCase):
def setUp(self):
self.osbuild = test.OSBuild()
def test_invalid_manifest(self):
invalid = json.dumps({"foo": 42})
with self.osbuild as osb, self.assertRaises(subprocess.CalledProcessError) as e:
osb.compile(invalid, check=True)
self.assertEqual(e.exception.returncode, 2)
def test_invalid_checkpoint(self):
manifest = json.dumps({})
with self.osbuild as osb, self.assertRaises(subprocess.CalledProcessError) as e:
osb.compile(manifest, checkpoints=["f44f76973fb92446a2a33bfdb401361a47f70497"], check=True)
self.assertEqual(e.exception.returncode, 1)