Exemplo n.º 1
0
def test_exec_hook_02():
    spec = 'touch test-exec-hook-01 && touch test-exec-hook-02'
    with TemporaryDirectory() as d:
        exec_hook(spec, d, 'test-exec-hook')
        assert os.path.exists(os.path.join(d, 'test-exec-hook-01'))
        assert os.path.exists(os.path.join(d, 'test-exec-hook-02'))
    assert not os.path.exists(d)
Exemplo n.º 2
0
def test_exec_hook_07():
    os.chdir('/')
    spec = 'flock --nonblock /var/lock/focker.lock -c ls'
    focker_lock()
    assert fcntl.flock(focker_lock.fd, fcntl.LOCK_EX | fcntl.LOCK_NB) != 0
    with TemporaryDirectory() as d:
        exec_hook(spec, d, 'test-exec-hook')
    assert fcntl.flock(focker_lock.fd, fcntl.LOCK_EX | fcntl.LOCK_NB) != 0
    focker_unlock()
Exemplo n.º 3
0
def test_exec_hook_06():
    spec = '/non-existent-command/hf249h'
    with TemporaryDirectory() as d:
        with pytest.raises(RuntimeError):
            exec_hook(spec, d, 'test-exec-hook')
Exemplo n.º 4
0
def test_exec_hook_05():
    spec = 'ls'
    oldwd = os.getcwd()
    with TemporaryDirectory() as d:
        exec_hook(spec, d, 'test-exec-hook')
    assert os.getcwd() == oldwd
Exemplo n.º 5
0
def test_exec_hook_04():
    spec = 'ls'
    with pytest.raises(FileNotFoundError):
        exec_hook(spec, '/non-existent-directory/wcj20fy103', 'test-exec-hook')
Exemplo n.º 6
0
def test_exec_hook_03b():
    spec = [1]
    with TemporaryDirectory() as d:
        with pytest.raises(TypeError):
            exec_hook(spec, d, 'test-exec-hook')
Exemplo n.º 7
0
def test_exec_hook_03a():
    spec = 1
    with TemporaryDirectory() as d:
        with pytest.raises(ValueError):
            exec_hook(spec, d, 'test-exec-hook')