api: extract base class

Split out the part of `api.API` that is responsible for providing
the server infrastructure for the API; i.e. setting up the server
and the corresponding context manager and asynchronous event
handling. This leaves `API` itself which just the implementation
of the high level protocol and makes the API-server part re-usable.

NB: pylint, for some reason, confuses `API` and `BaseAPI`, like in
`test_monitor`. Annotate that accordingly.
This commit is contained in:
Christian Kellner 2020-07-22 15:24:33 +02:00 committed by Tom Gundersen
parent 2423bf12f0
commit 1ce517e595
2 changed files with 73 additions and 23 deletions

View file

@ -93,7 +93,7 @@ class TestMonitor(unittest.TestCase):
p.start()
p.join()
self.assertEqual(p.exitcode, 0)
output = api.output
output = api.output # pylint: disable=no-member
assert output
self.assertEqual(json.dumps(args), output)