Example #1
0
def test_check_all_updates(mocked_info, mocked_error, mocked_call,
                           mocked_check_updates):

    update_generator = updater.check_all_updates()
    results = {}

    for vm, progress, result in update_generator:
        results[vm] = result
        assert progress is not None
        results[vm] = result

    check_updates_call_list = [call(x) for x in current_templates.keys()]
    mocked_check_updates.assert_has_calls(check_updates_call_list)

    assert not mocked_call.called
    assert not mocked_error.called
    assert updater.overall_update_status(results) == UpdateStatus.UPDATES_OK
Example #2
0
    status = updater._check_updates_debian("sd-log")
    assert status == UpdateStatus.UPDATES_REQUIRED

    mocked_error.assert_has_calls(error_log)
    mocked_info.assert_has_calls(info_log)


@mock.patch("Updater.sdlog.error")
@mock.patch("Updater.sdlog.info")
def test_check_updates_fedora_calls_fedora(mocked_info, mocked_error):
    status = updater.check_updates("fedora")
    assert status == UpdateStatus.UPDATES_REQUIRED


@pytest.mark.parametrize("vm", current_templates.keys())
@mock.patch("subprocess.check_call")
@mock.patch("Updater.sdlog.error")
@mock.patch("Updater.sdlog.info")
def test_check_updates_calls_correct_commands(mocked_info, mocked_error,
                                              mocked_call, vm):
    status = updater.check_updates(vm)
    if vm == "fedora":
        assert status == UpdateStatus.UPDATES_REQUIRED
    else:
        assert status == UpdateStatus.UPDATES_OK

    if vm in debian_based_vms:
        subprocess_call_list = [
            call(["qvm-run", current_templates[vm], "sudo apt update"]),
            call([