[tests] /halfapi/schema
This commit is contained in:
parent
2819483070
commit
15d69efd60
|
@ -42,7 +42,7 @@ class DomainMiddleware(BaseHTTPMiddleware):
|
|||
|
||||
self.domains = self.config.get('domains', {})
|
||||
|
||||
if len(domain) == 0:
|
||||
if len(domain) == 0 or domain == 'halfapi':
|
||||
for domain in self.domains:
|
||||
self.api[domain], self.acl[domain] = api_routes(self.domains[domain])
|
||||
elif domain in self.domains:
|
||||
|
|
|
@ -6,6 +6,7 @@ from starlette.authentication import (
|
|||
UnauthenticatedUser)
|
||||
|
||||
from halfapi.lib.schemas import schema_dict_dom
|
||||
from halfapi import __version__
|
||||
|
||||
def test_schemas_dict_dom():
|
||||
from .dummy_domain import routers
|
||||
|
@ -20,6 +21,17 @@ def test_get_api_routes(project_runner, application_debug):
|
|||
d_r = r.json()
|
||||
assert isinstance(d_r, dict)
|
||||
|
||||
def test_get_schema_route(project_runner, application_debug):
|
||||
c = TestClient(application_debug)
|
||||
r = c.get('/halfapi/schema')
|
||||
d_r = r.json()
|
||||
assert isinstance(d_r, dict)
|
||||
assert 'openapi' in d_r.keys()
|
||||
assert 'info' in d_r.keys()
|
||||
assert d_r['info']['title'] == 'HalfAPI'
|
||||
assert d_r['info']['version'] == __version__
|
||||
assert 'paths' in d_r.keys()
|
||||
|
||||
|
||||
def test_get_api_dummy_domain_routes(application_domain, routers):
|
||||
c = TestClient(application_domain)
|
||||
|
@ -27,7 +39,6 @@ def test_get_api_dummy_domain_routes(application_domain, routers):
|
|||
assert r.status_code == 200
|
||||
d_r = r.json()
|
||||
assert isinstance(d_r, dict)
|
||||
print(d_r)
|
||||
assert 'abc/alphabet' in d_r
|
||||
assert 'GET' in d_r['abc/alphabet']
|
||||
assert len(d_r['abc/alphabet']['GET']) > 0
|
||||
|
|
Loading…
Reference in New Issue