async def _test(): c = fastapi_plugins.Controller() exp = dict(status=True, checks=[]) res = (await c.get_health()).dict() self.assertTrue( d2json(exp) == d2json(res), 'health failed: %s != %s' % (exp, res))
async def _test(): app = fastapi.FastAPI() config = fastapi_plugins.ControlSettings() dummy = DummyPluginHealthFail() await dummy.init_app(app, config) await dummy.init() try: c = fastapi_plugins.Controller() c.plugins.append(('DUMMY_PLUGIN_HEALTH_FAIL', dummy)) exp = dict(status=False, checks=[ dict(name='DUMMY_PLUGIN_HEALTH_FAIL', status=False, details=dict(error='Health check failed')) ]) res = (await c.get_health()).dict() self.assertTrue( d2json(exp) == d2json(res), 'health failed: %s != %s' % (exp, res)) finally: await dummy.terminate()
async def _test(): v = '1.2.3' c = fastapi_plugins.Controller(version=v) r = await c.get_version() self.assertTrue(r == v, 'version failed')
async def _test(): from fastapi_plugins.control import DEFAULT_CONTROL_VERSION c = fastapi_plugins.Controller() r = await c.get_version() self.assertTrue(r == DEFAULT_CONTROL_VERSION, 'version failed')
async def _test(): c = fastapi_plugins.Controller() exp = True res = await c.get_heart_beat() self.assertTrue(exp == res, 'heart beat failed: %s != %s' % (exp, res))
async def _test(): exp = dict(ping='pong') c = fastapi_plugins.Controller(environ=exp) res = await c.get_environ() self.assertTrue(d2json(exp) == d2json(res), 'environ failed')
async def _test(): c = fastapi_plugins.Controller() res = await c.get_environ() exp = {} self.assertTrue(d2json(exp) == d2json(res), 'environ failed')