44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
|
|
from pathlib import Path
|
||
|
|
from os import chdir
|
||
|
|
|
||
|
|
from rougail.cli.__main__ import main
|
||
|
|
|
||
|
|
|
||
|
|
test_dir = Path(__file__).parent
|
||
|
|
|
||
|
|
|
||
|
|
def test_cli():
|
||
|
|
chdir(test_dir / 'cli')
|
||
|
|
ret = main(['--main_dictionaries', 'structures'], do_not_print=True)
|
||
|
|
filename = Path('result.txt')
|
||
|
|
if not filename.is_file():
|
||
|
|
with filename.open('w') as fh:
|
||
|
|
fh.write(ret[1])
|
||
|
|
with filename.open() as fh:
|
||
|
|
data = fh.read()
|
||
|
|
assert ret == (True, data)
|
||
|
|
|
||
|
|
|
||
|
|
def test_cli_boolean():
|
||
|
|
chdir(test_dir / 'cli')
|
||
|
|
ret = main(['--main_dictionaries', 'structures', '--console.mandatory'], do_not_print=True)
|
||
|
|
filename = Path('result.txt')
|
||
|
|
if not filename.is_file():
|
||
|
|
with filename.open('w') as fh:
|
||
|
|
fh.write(ret[1])
|
||
|
|
with filename.open() as fh:
|
||
|
|
data = fh.read()
|
||
|
|
assert ret == (True, data)
|
||
|
|
|
||
|
|
|
||
|
|
def test_cli_boolean_2():
|
||
|
|
chdir(test_dir / 'cli')
|
||
|
|
ret = main(['--main_dictionaries', 'structures', '--console.no-mandatory'], do_not_print=True)
|
||
|
|
filename = Path('result.txt')
|
||
|
|
if not filename.is_file():
|
||
|
|
with filename.open('w') as fh:
|
||
|
|
fh.write(ret[1])
|
||
|
|
with filename.open() as fh:
|
||
|
|
data = fh.read()
|
||
|
|
assert ret == (True, data)
|