Esempio n. 1
0
def test_cmd_execution_failed_gives_command_in_exception(mockroot):
    c = Component()
    c.prepare(mockroot)
    with pytest.raises(CmdExecutionError) as e:
        c.cmd('asdf')
    assert e.value.cmd == 'asdf'
    assert e.value.returncode == 127
Esempio n. 2
0
def test_assert_cmd_when_unsuccessful(mockroot):
    c = Component()
    c.prepare(mockroot)
    with pytest.raises(UpdateNeeded):
        c.assert_cmd('false')
Esempio n. 3
0
def test_assert_cmd_when_succesful(mockroot):
    c = Component()
    c.prepare(mockroot)
    c.assert_cmd('true')
Esempio n. 4
0
def test_cmd_should_not_stop_if_process_expects_input(mockroot):
    c = Component()
    c.prepare(mockroot)
    stdout, stderr = c.cmd('cat')
Esempio n. 5
0
def test_cmd_returns_output_if_ignore_returncode(mockroot):
    c = Component()
    c.prepare(mockroot)
    out, err = c.cmd('echo important output && false', ignore_returncode=True)
    assert 'important output\n' == out
Esempio n. 6
0
def test_cmd_raises_if_error(mockroot):
    c = Component()
    c.prepare(mockroot)
    with pytest.raises(CmdExecutionError):
        c.cmd('non-existing-command')
Esempio n. 7
0
def test_cmd_returns_output(mockroot):
    c = Component()
    c.prepare(mockroot)
    assert ('1\n', '') == c.cmd('echo 1')
Esempio n. 8
0
def test_cmd_expands_jinja(mockroot):
    c = Component()
    c.foo = 'asdf'
    c.prepare(mockroot)
    assert ('asdf\n', '') == c.cmd('echo "{{component.foo}}"')
Esempio n. 9
0
def test_cmd_returns_output(mockroot):
    c = Component()
    c.prepare(mockroot)
    assert ("1\n", "") == c.cmd("echo 1")
Esempio n. 10
0
def test_cmd_expands_jinja(mockroot):
    c = Component()
    c.foo = "asdf"
    c.prepare(mockroot)
    assert ("asdf\n", "") == c.cmd('echo "{{component.foo}}"')