Exemplo n.º 1
0
async def test_interactive_command(capsys, monkeypatch):
    async def mocked_prepare_execute(req, arg):
        print(req)

    inputs = ['req1', 'req2', '\x03']

    def mocked_input(prompt):
        i = inputs.pop(0)
        if i == '\x03':
            raise SystemExit()
        return i

    monkeypatch.setattr('builtins.input', mocked_input)
    monkeypatch.setattr(commands, 'prepare_and_execute_request',
                        mocked_prepare_execute)
    with pytest.raises(SystemExit):
        await interactive_command({})
    captured = capsys.readouterr()
    assert escape_ansi(
        captured.out) == '''Dbgr interactive mode; press ^C to exit.
Exemplo n.º 2
0
def test_format_without_type():
    r = Result('string value')
    assert escape_ansi(r) == 'string value'
Exemplo n.º 3
0
def test_format_none():
    r = Result(None, Type(), False)
    assert escape_ansi(r) == 'None'
Exemplo n.º 4
0
async def test_list_command_module_not_found(monkeypatch, capsys):
    requests = {'module': {'req': mock_request(name='req', module='module')}}
    monkeypatch.setattr(commands, 'get_requests', lambda: requests)
    await list_command(attrdict({'module': 'module_404'}))
    captured = capsys.readouterr()
    assert escape_ansi(captured.out) == 'Module "module_404" does not exist.\n'
Exemplo n.º 5
0
async def test_list_command_no_requests(monkeypatch, capsys):
    monkeypatch.setattr(commands, 'get_requests', lambda: {})
    await list_command(attrdict({'module': None}))
    captured = capsys.readouterr()
    assert escape_ansi(captured.out) == 'No requests found.\n'
Exemplo n.º 6
0
async def test_environments_command_list_environments(capsys, monkeypatch):
    monkeypatch.setattr(commands, 'get_environments',
                        lambda: ['default', 'another'])
    await environments_command(attrdict({'environment': None}))
    captured = capsys.readouterr()
    assert escape_ansi(captured.out) == '- default\n- another\n'
Exemplo n.º 7
0
def test_version_command(capsys):
    version_command()
    captured = capsys.readouterr()
    assert escape_ansi(captured.out) == f'{meta.__version__}\n'