2020-08-06 23:39:04 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import importlib
|
|
|
|
import tempfile
|
|
|
|
from unittest.mock import patch
|
2022-08-05 09:37:17 +02:00
|
|
|
import json
|
2020-08-06 23:39:04 +02:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
from click.testing import CliRunner
|
|
|
|
from configparser import ConfigParser
|
|
|
|
|
|
|
|
PROJNAME = os.environ.get('PROJ','tmp_api')
|
|
|
|
|
|
|
|
|
|
|
|
class TestCliProj():
|
2020-09-25 01:06:21 +02:00
|
|
|
def test_cmds(self, project_runner):
|
|
|
|
assert project_runner('--help').exit_code == 0
|
|
|
|
#assert project_runner('run', '--help').exit_code == 0
|
|
|
|
#assert project_runner('domain', '--help').exit_code == 0
|
|
|
|
|
|
|
|
|
2020-10-07 09:52:23 +02:00
|
|
|
def test_domain_commands(self, project_runner):
|
2021-12-01 13:31:46 +01:00
|
|
|
""" TODO: Test create command
|
|
|
|
"""
|
2020-10-07 09:52:23 +02:00
|
|
|
r = project_runner('domain')
|
2021-12-01 13:31:46 +01:00
|
|
|
print(r.stdout)
|
|
|
|
assert r.exit_code == 1
|
2022-08-05 09:37:17 +02:00
|
|
|
_, tmp_conf = tempfile.mkstemp()
|
|
|
|
with open(tmp_conf, 'w') as fh:
|
|
|
|
fh.write(
|
|
|
|
json.dumps({
|
|
|
|
'domain': {
|
|
|
|
'dummy_domain': {
|
|
|
|
'name': 'dummy_domain',
|
|
|
|
'enabled': True
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
r = project_runner(f'domain dummy_domain {tmp_conf}')
|
2021-12-01 13:31:46 +01:00
|
|
|
print(r.stdout)
|
2020-10-07 09:52:23 +02:00
|
|
|
assert r.exit_code == 0
|
2020-09-25 01:06:21 +02:00
|
|
|
|
2021-12-01 13:31:46 +01:00
|
|
|
|
2020-10-07 09:52:23 +02:00
|
|
|
def test_config_commands(self, project_runner):
|
|
|
|
try:
|
|
|
|
r = project_runner('config')
|
|
|
|
assert r.exit_code == 0
|
|
|
|
except AssertionError as exc:
|
|
|
|
subprocess.call(['tree', '-a'])
|
|
|
|
raise exc
|
2020-08-06 23:39:04 +02:00
|
|
|
|