api: use more generic error member for exceptions
Rename the `API.exception` member to `API.error`, to make it more generic, so it can also be used for other sort of errors in the future. Also add a layer of additional structure with `type` and `data` members so different types of errors apart. Currently only `exception` is used. Adapt the tests in test/mod/test_api.py to check for the new structure and its content.
This commit is contained in:
parent
17fbe41b03
commit
f5d00dd043
3 changed files with 14 additions and 6 deletions
|
|
@ -96,8 +96,13 @@ class TestAPI(unittest.TestCase):
|
|||
p = mp.Process(target=exception, args=(path, ))
|
||||
p.start()
|
||||
p.join()
|
||||
self.assertIsNotNone(api.exception, "Exception not set")
|
||||
self.assertEqual(api.exception["value"], "osbuild test exception")
|
||||
self.assertIsNotNone(api.error, "Error not set")
|
||||
self.assertIn("type", api.error, "Error has no 'type' set")
|
||||
self.assertEqual("exception", api.error["type"], "Not an exception")
|
||||
e = api.error["data"]
|
||||
for field in ("type", "value", "traceback"):
|
||||
self.assertIn(field, e, f"Exception needs '{field}'")
|
||||
self.assertEqual(e["value"], "osbuild test exception")
|
||||
|
||||
def test_metadata(self):
|
||||
# Check that `api.metadata` leads to `API.metadata` being
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue