Exemple #1
0
def test_add(daemon_setup):
    """The daemon adds a  new task to its queue."""
    command_factory("pause")
    response = send_command({"mode": "add", "command": "ls", "path": "/tmp", "status": "queued", "returncode": ""})
    assert response["status"] == "success"
    status = get_status()
    assert status["data"][0]["command"] == "ls"
    assert status["data"][0]["path"] == "/tmp"
Exemple #2
0
def test_switch_running(daemon_setup):
    """Switching the position of running command fails."""
    execute_add({'command': 'sleep 60'})
    execute_add({'command': 'ls -l'})
    response = send_command({
        'mode': 'switch',
        'first': 0,
        'second': 1
    })
    assert response['status'] == 'error'
Exemple #3
0
def test_restart(daemon_setup):
    """Restart a command."""
    execute_add({'command': 'ls'})
    wait_for_process(0)
    response = send_command({'mode': 'restart', 'key': 0})
    assert response['status'] == 'success'
    status = get_status()
    assert len(status['data']) == 2
    assert status['data'][1]['path'] == status['data'][0]['path']
    assert status['data'][1]['command'] == status['data'][0]['command']
Exemple #4
0
def test_remove(daemon_setup):
    """Remove a process from the queue."""
    command_factory("pause")
    status = get_status()
    assert status["status"] == "paused"
    execute_add({"command": "ls"})

    response = send_command({"mode": "remove", "key": 0})
    assert response["status"] == "success"
    status = get_status()
    assert status["data"] == "Queue is empty"
Exemple #5
0
def test_switch_fails(daemon_setup):
    """Switching the position of a not existing command fails."""
    response = send_command({'mode': 'switch', 'first': 0, 'second': 1})
    assert response['status'] == 'error'
Exemple #6
0
def test_remove_running(daemon_setup):
    """Can't remove a running process."""
    execute_add({"command": "sleep 60"})
    response = send_command({"mode": "remove", "key": 0})
    assert response["status"] == "error"
Exemple #7
0
def test_remove_fails(daemon_setup):
    """Fail if removing a non existant key."""
    response = send_command({"mode": "remove", "key": 0})
    assert response["status"] == "error"
Exemple #8
0
def test_restart_fails(daemon_setup):
    """Fail if restarting a non existant key."""
    response = send_command({'mode': 'remove', 'key': 0})
    assert response['status'] == 'error'
Exemple #9
0
def test_restart_running(daemon_setup):
    """Restart a running command fails."""
    execute_add({'command': 'sleep 5'})
    response = send_command({'mode': 'restart', 'key': 0})
    assert response['status'] == 'error'