Ejemplo n.º 1
0
def test_remove_scheduling_systemd_not_found(run_command_get_output):
    schedule = sched.InsightsSchedulerSystemd()
    run_command_get_output.reset_mock()

    unscheduled = schedule.remove_scheduling()
    assert unscheduled == {}
    run_command_get_output.assert_not_called()
Ejemplo n.º 2
0
def test_active_systemd_active(run_command_get_output, outputs):
    run_command_get_output.side_effect = ({
        "status": 0,
        "output": output
    } for output in outputs)
    schedule = sched.InsightsSchedulerSystemd()
    assert schedule.active is True
Ejemplo n.º 3
0
def test_remove_scheduling_systemd_init_error(run_command_get_output):
    schedule = sched.InsightsSchedulerSystemd()
    run_command_get_output.reset_mock()

    unscheduled = schedule.remove_scheduling()
    assert unscheduled is None
    run_command_get_output.assert_not_called()
Ejemplo n.º 4
0
def test_schedule_systemd_not_found(run_command_get_output):
    schedule = sched.InsightsSchedulerSystemd()
    run_command_get_output.reset_mock()

    scheduled = schedule.schedule()
    assert scheduled == {}
    run_command_get_output.assert_not_called()
Ejemplo n.º 5
0
def test_schedule_systemd_success(run_command_get_output, outputs):
    run_command_get_output.side_effect = ({
        "status": 0,
        "output": output
    } for output in outputs)
    schedule = sched.InsightsSchedulerSystemd()
    scheduled = schedule.schedule()
    assert scheduled is True
Ejemplo n.º 6
0
def test_init_calls(run_command_get_output):
    sched.InsightsSchedulerSystemd()
    calls = (
        call("systemctl show --property LoadState insights-client.timer"),
        call(
            "systemctl show --property LoadState insights-client-checkin.timer"
        ),
    )
    run_command_get_output.assert_has_calls(calls)
Ejemplo n.º 7
0
def test_init_systemd_loaded_timers(run_command_get_output, load_states,
                                    loaded_timers):
    run_command_get_output.side_effect = ({
        "status":
        0,
        "output":
        "LoadState=%s\n" % load_state
    } for load_state in load_states)
    scheduler = sched.InsightsSchedulerSystemd()
    assert scheduler.loaded_timers == loaded_timers
Ejemplo n.º 8
0
def test_active_systemd_calls(run_command_get_output, outputs, calls):
    run_command_get_output.side_effect = ({
        "status": 0,
        "output": output
    } for output in outputs)

    schedule = sched.InsightsSchedulerSystemd()
    run_command_get_output.reset_mock()
    schedule.active

    run_command_get_output.assert_has_calls(calls)
Ejemplo n.º 9
0
def test_init_systemd_error(run_command_get_output, side_effect):
    run_command_get_output.side_effect = side_effect
    scheduler = sched.InsightsSchedulerSystemd()
    assert scheduler.loaded_timers is None
Ejemplo n.º 10
0
def test_active_systemd_init_error(run_command_get_output):
    schedule = sched.InsightsSchedulerSystemd()
    run_command_get_output.reset_mock()

    assert schedule.active is None
    run_command_get_output.assert_not_called()
Ejemplo n.º 11
0
def test_active_systemd_error(run_command_get_output, side_effect):
    run_command_get_output.side_effect = side_effect
    schedule = sched.InsightsSchedulerSystemd()
    assert schedule.active is None
Ejemplo n.º 12
0
def test_remove_scheduling_systemd_error(run_command_get_output, side_effect):
    run_command_get_output.side_effect = side_effect

    schedule = sched.InsightsSchedulerSystemd()
    unscheduled = schedule.remove_scheduling()
    assert unscheduled is None
Ejemplo n.º 13
0
def test_schedule_systemd_call_error(run_command_get_output, side_effect):
    run_command_get_output.side_effect = side_effect

    schedule = sched.InsightsSchedulerSystemd()
    scheduled = schedule.schedule()
    assert scheduled is None
Ejemplo n.º 14
0
def test_schedule_systemd_inactive(run_command_get_output, side_effect):
    run_command_get_output.side_effect = side_effect

    schedule = sched.InsightsSchedulerSystemd()
    scheduled = schedule.schedule()
    assert scheduled is False