Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_cli_start_exception_service_init(monkeypatch: Any, capsys: Any) -> None:
monkeypatch.setattr(logging.root, 'handlers', [])
with pytest.raises(SystemExit):
tomodachi.cli.cli_entrypoint(['tomodachi', 'run', 'tests/services/exception_service_init.py'])
out, err = capsys.readouterr()
assert err != ''
assert 'Starting services' in out
assert 'tomodachi/{}'.format(tomodachi.__version__) in out
assert 'fail in __init__()' in err
def test_cli_entrypoint_print_dependency_versions(monkeypatch: Any, capsys: Any) -> None:
monkeypatch.setattr(logging.root, 'handlers', [])
with pytest.raises(SystemExit):
tomodachi.cli.cli_entrypoint(['tomodachi', '--dependency-versions'])
out, err = capsys.readouterr()
assert err == ''
assert out != 'tomodachi/{}'.format(tomodachi.__version__) + "\n"
import aiobotocore
assert 'aiobotocore/{}'.format(aiobotocore.__version__) + "\n" in out
def test_cli_entrypoint_print_version(monkeypatch: Any, capsys: Any) -> None:
monkeypatch.setattr(logging.root, 'handlers', [])
with pytest.raises(SystemExit):
tomodachi.cli.cli_entrypoint(['tomodachi', '-v'])
out, err = capsys.readouterr()
assert err == ''
assert out == 'tomodachi/{}'.format(tomodachi.__version__) + "\n"
def test_cli_start_service_with_invalid_config(monkeypatch: Any, capsys: Any) -> None:
monkeypatch.setattr(logging.root, 'handlers', [])
with pytest.raises(SystemExit):
tomodachi.cli.cli_entrypoint(['tomodachi', 'run', 'tests/services/auto_closing_service.py', '-c', 'tests/configs/invalid_config_file.json'])
out, err = capsys.readouterr()
assert 'Starting services' not in out
assert 'tomodachi/{}'.format(tomodachi.__version__) not in out
assert 'Invalid config file, invalid JSON format' in out
def test_cli_start_service_with_non_existing_config(monkeypatch: Any, capsys: Any) -> None:
monkeypatch.setattr(logging.root, 'handlers', [])
with pytest.raises(SystemExit):
tomodachi.cli.cli_entrypoint(['tomodachi', 'run', 'tests/services/auto_closing_service.py', '-c', 'tests/configs/without_config_file.json'])
out, err = capsys.readouterr()
assert 'Starting services' not in out
assert 'tomodachi/{}'.format(tomodachi.__version__) not in out
assert 'Invalid config file' in out
def test_cli_entrypoint_invalid_arguments_show_help(monkeypatch: Any, capsys: Any) -> None:
cli = tomodachi.cli.CLI()
monkeypatch.setattr(logging.root, 'handlers', [])
with pytest.raises(SystemExit):
tomodachi.cli.cli_entrypoint(['tomodachi', '--invalid'])
out, err = capsys.readouterr()
assert err == ''
assert out == cli.help_command_usage() + "\n"
def test_cli_entrypoint_print_help(monkeypatch: Any, capsys: Any) -> None:
cli = tomodachi.cli.CLI()
monkeypatch.setattr(logging.root, 'handlers', [])
with pytest.raises(SystemExit):
tomodachi.cli.cli_entrypoint(['tomodachi', '-h'])
out, err = capsys.readouterr()
assert err == ''
assert out == cli.help_command_usage() + "\n"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""tomodachi.py: microservice framework"""
import sys
if __name__ == "__main__":
if not sys.version_info >= (3, 6):
print("tomodachi doesn't support Python earlier than 3.6")
sys.exit(1)
import tomodachi.cli
tomodachi.cli.cli_entrypoint()
#!/usr/bin/env python
import tomodachi.cli
if __name__ == "__main__":
tomodachi.cli.cli_entrypoint()