manipuler le sys.path : BAAAD
This commit is contained in:
parent
e293ac3867
commit
5e88109b3e
|
@ -50,8 +50,6 @@ def run(host, port, reload, secret, production, loglevel, prefix, check, schema,
|
||||||
|
|
||||||
click.echo(f'Launching application {PROJECT_NAME}')
|
click.echo(f'Launching application {PROJECT_NAME}')
|
||||||
|
|
||||||
sys.path.insert(0, os.getcwd())
|
|
||||||
|
|
||||||
CONFIG.get('domain')['name'] = domain
|
CONFIG.get('domain')['name'] = domain
|
||||||
CONFIG.get('domain')['router'] = router
|
CONFIG.get('domain')['router'] = router
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,6 @@ def d_domains(config) -> Dict[str, ModuleType]:
|
||||||
domains = dict(config['domains'].items())
|
domains = dict(config['domains'].items())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sys.path.append('.')
|
|
||||||
return {
|
return {
|
||||||
domain: importlib.import_module(''.join((domain, module)))
|
domain: importlib.import_module(''.join((domain, module)))
|
||||||
for domain, module in domains.items()
|
for domain, module in domains.items()
|
||||||
|
|
|
@ -258,7 +258,6 @@ def create_route():
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def dummy_project():
|
def dummy_project():
|
||||||
sys.path.insert(0, './tests')
|
|
||||||
halfapi_config = tempfile.mktemp()
|
halfapi_config = tempfile.mktemp()
|
||||||
halfapi_secret = tempfile.mktemp()
|
halfapi_secret = tempfile.mktemp()
|
||||||
domain = 'dummy_domain'
|
domain = 'dummy_domain'
|
||||||
|
@ -281,18 +280,10 @@ def dummy_project():
|
||||||
with open(halfapi_secret, 'w') as f:
|
with open(halfapi_secret, 'w') as f:
|
||||||
f.write('turlututu')
|
f.write('turlututu')
|
||||||
|
|
||||||
return (halfapi_config, 'dummy_domain', 'routers')
|
return (halfapi_config, 'dummy_domain', 'dummy_domain.routers')
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def routers():
|
def application_debug(project_runner):
|
||||||
sys.path.insert(0, './tests')
|
|
||||||
|
|
||||||
from .dummy_domain import routers
|
|
||||||
return routers
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def application_debug(routers):
|
|
||||||
halfAPI = HalfAPI({
|
halfAPI = HalfAPI({
|
||||||
'secret':'turlututu',
|
'secret':'turlututu',
|
||||||
'production':False,
|
'production':False,
|
||||||
|
|
|
@ -16,29 +16,6 @@ def test_schemas_dict_dom():
|
||||||
'dummy_domain':routers})
|
'dummy_domain':routers})
|
||||||
assert isinstance(schema, dict)
|
assert isinstance(schema, dict)
|
||||||
|
|
||||||
def test_get_api_schema(project_runner, application_debug):
|
|
||||||
c = TestClient(application_debug)
|
|
||||||
r = c.get('/')
|
|
||||||
assert isinstance(c, TestClient)
|
|
||||||
d_r = r.json()
|
|
||||||
assert isinstance(d_r, dict)
|
|
||||||
pprint(d_r)
|
|
||||||
assert API_SCHEMA.validate(d_r)
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
def test_get_api_dummy_domain_routes(application_domain, routers):
|
|
||||||
c = TestClient(application_domain)
|
|
||||||
r = c.get('/dummy_domain')
|
|
||||||
assert r.status_code == 200
|
|
||||||
d_r = r.json()
|
|
||||||
assert isinstance(d_r, dict)
|
|
||||||
assert 'abc/alphabet' in d_r
|
|
||||||
assert 'GET' in d_r['abc/alphabet']
|
|
||||||
assert len(d_r['abc/alphabet']['GET']) > 0
|
|
||||||
assert 'acls' in d_r['abc/alphabet']['GET']
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test_schema_to_csv():
|
def test_schema_to_csv():
|
||||||
csv = schema_to_csv('dummy_domain.routers', False)
|
csv = schema_to_csv('dummy_domain.routers', False)
|
||||||
assert isinstance(csv, str)
|
assert isinstance(csv, str)
|
||||||
|
|
Loading…
Reference in New Issue