[testing] set starlette client in setUp
This commit is contained in:
parent
e9ffb553c8
commit
f02a97fbf8
|
@ -17,6 +17,7 @@ class TestDomain(TestCase):
|
||||||
return '.'.join((self.DOMAIN, self.ROUTERS))
|
return '.'.join((self.DOMAIN, self.ROUTERS))
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
# CLI
|
||||||
class_ = CliRunner
|
class_ = CliRunner
|
||||||
def invoke_wrapper(f):
|
def invoke_wrapper(f):
|
||||||
"""Augment CliRunner.invoke to emit its output to stdout.
|
"""Augment CliRunner.invoke to emit its output to stdout.
|
||||||
|
@ -40,6 +41,26 @@ class TestDomain(TestCase):
|
||||||
class_.invoke = invoke_wrapper(class_.invoke)
|
class_.invoke = invoke_wrapper(class_.invoke)
|
||||||
self.runner = class_(mix_stderr=False)
|
self.runner = class_(mix_stderr=False)
|
||||||
|
|
||||||
|
# HTTP
|
||||||
|
self.halfapi_conf = {
|
||||||
|
'domain': {}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.halfapi_conf['domain'][self.DOMAIN] = {
|
||||||
|
'name': self.DOMAIN,
|
||||||
|
'router': self.ROUTERS,
|
||||||
|
'prefix': False,
|
||||||
|
'enabled': True,
|
||||||
|
'config': {
|
||||||
|
'test': True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.halfapi = HalfAPI(self.halfapi_conf)
|
||||||
|
|
||||||
|
self.client = TestClient(self.halfapi.application)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
|
@ -66,24 +87,7 @@ class TestDomain(TestCase):
|
||||||
return result_d
|
return result_d
|
||||||
|
|
||||||
def check_routes(self):
|
def check_routes(self):
|
||||||
halfapi_conf = {
|
r = self.client.get('/')
|
||||||
'domain': {}
|
|
||||||
}
|
|
||||||
|
|
||||||
halfapi_conf['domain'][self.DOMAIN] = {
|
|
||||||
'name': self.DOMAIN,
|
|
||||||
'router': self.ROUTERS,
|
|
||||||
'prefix': False,
|
|
||||||
'enabled': True,
|
|
||||||
'config': {
|
|
||||||
'test': True
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
halfapi = HalfAPI(halfapi_conf)
|
|
||||||
|
|
||||||
client = TestClient(halfapi.application)
|
|
||||||
r = client.get('/')
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
schemas = r.json()
|
schemas = r.json()
|
||||||
assert isinstance(schemas, list)
|
assert isinstance(schemas, list)
|
||||||
|
@ -94,7 +98,7 @@ class TestDomain(TestCase):
|
||||||
assert 'paths' in schema
|
assert 'paths' in schema
|
||||||
assert 'domain' in schema
|
assert 'domain' in schema
|
||||||
|
|
||||||
r = client.get('/halfapi/acls')
|
r = self.client.get('/halfapi/acls')
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
d_r = r.json()
|
d_r = r.json()
|
||||||
assert isinstance(d_r, dict)
|
assert isinstance(d_r, dict)
|
||||||
|
|
Loading…
Reference in New Issue