Пример #1
0
def test_fyoo_context_wrong_format(context, context_format,
                                   expected_exception_cls):
    with pytest.raises(expected_exception_cls):
        main([
            f'--context={context}', f'--context-format={context_format}', '--',
            'echo', '-n', r'{{ a }} {{ date() }}'
        ])
Пример #2
0
def test_fyoo_context_auto_format(os_execvp):
    main([
        r'--context={"a": {"b": "AAA"}}', '--', 'echo', '-n',
        r'{{ a.b }} {{ date() }}'
    ])
    os_execvp.assert_called_once_with('echo',
                                      ['echo', '-n', f'AAA {TODAY_DT_DS}'])
Пример #3
0
def test_double_exec(os_execvp):
    main([f'--', 'echo', '--', '-n', r'{{ a }} {{ date() }}'])
    os_execvp.assert_called_once_with('echo',
                                      ['echo', '--', '-n', f' {TODAY_DT_DS}'])
Пример #4
0
def test_fyoo_command_not_exist_error():
    with pytest.raises(SystemExit):
        main(['--', 'idontexistascommand'])
Пример #5
0
def test_fyoo_dry_run_stops(os_execvp):
    main([f'--dry-run', '--', 'echo', '-n', 'hello'])
    os_execvp.assert_not_called()
Пример #6
0
def test_fyoo_context_bad_format():
    with pytest.raises(ValueError):
        main([
            f'--context=a: b: 333', '--', 'echo', '-n', r'{{ a }} {{ date() }}'
        ])
Пример #7
0
def test_unknown_arg_fails(capsys):
    with pytest.raises(SystemExit) as e:
        main(['asdf'])
    out: CaptureResult = capsys.readouterr()
    assert e.value.code == 2
    assert 'invalid choice' in out.err
Пример #8
0
def test_no_arg_fails(capsys):
    with pytest.raises(SystemExit) as e:
        main([])
    out: CaptureResult = capsys.readouterr()
    assert e.value.code == 2
    assert 'Please provide a subcommand' in out.err
Пример #9
0
from fyoo.cli import main

if __name__ == '__main__':
    main()