Beispiel #1
0
def test_check_system_opts(m_utils):
    opts = install.InstallOptions()

    # no use defaults -> prompt
    m_utils.command_exists.return_value = True
    m_utils.confirm.return_value = True
    opts.check_system_opts()
    assert opts.apt_install is True
    assert m_utils.confirm.call_count == 1

    # use defaults -> no prompt
    opts.use_defaults = True
    m_utils.confirm.reset_mock()
    m_utils.confirm.return_value = False
    opts.check_system_opts()
    assert opts.apt_install is True
    assert m_utils.confirm.call_count == 0

    # apt not found -> no prompt
    opts.use_defaults = False
    m_utils.confirm.reset_mock()
    m_utils.confirm.return_value = True
    m_utils.command_exists.return_value = False
    opts.check_system_opts()
    assert opts.apt_install is False
    assert m_utils.confirm.call_count == 0
Beispiel #2
0
def test_check_reboot_opts(m_utils):
    opts = install.InstallOptions()

    opts.docker_install = False
    opts.docker_group_add = False
    m_utils.is_docker_user.return_value = False
    m_utils.confirm.return_value = True

    opts.check_reboot_opts()
    assert opts.reboot_needed is False
    assert m_utils.confirm.call_count == 0

    opts.docker_install = True
    opts.check_reboot_opts()
    assert opts.reboot_needed is True
    assert m_utils.confirm.call_count == 1
Beispiel #3
0
def test_check_init_opts(m_utils):
    opts = install.InstallOptions()

    m_utils.confirm.return_value = True
    m_utils.path_exists.return_value = True
    opts.check_init_opts()
    assert opts.init_compose is False
    assert opts.init_datastore is False
    assert opts.init_history is False
    assert opts.init_gateway is False
    assert opts.init_eventbus is False

    m_utils.path_exists.return_value = False
    opts.check_init_opts()
    assert opts.init_compose is True
    assert opts.init_datastore is True
    assert opts.init_history is True
    assert opts.init_gateway is True
    assert opts.init_eventbus is True
    assert m_utils.confirm.call_count == 5
Beispiel #4
0
def test_check_confirm_opts(m_utils):
    opts = install.InstallOptions()

    # use_defaults will be true, skip_confirm not asked
    m_utils.confirm.return_value = True

    opts.check_confirm_opts()

    assert opts.use_defaults is True
    assert opts.skip_confirm is True
    assert m_utils.confirm.call_count == 1

    # use_defaults False -> explicitly ask skip_confirm
    m_utils.confirm.reset_mock()
    m_utils.confirm.return_value = False

    opts.check_confirm_opts()

    assert opts.use_defaults is False
    assert opts.skip_confirm is False
    assert m_utils.confirm.call_count == 2
Beispiel #5
0
def test_check_docker_opts(m_utils):
    opts = install.InstallOptions()

    # Clean env -> prompt to install, add, pull
    m_utils.command_exists.return_value = False
    m_utils.is_docker_user.return_value = False
    m_utils.confirm.return_value = True
    opts.check_docker_opts()
    assert opts.docker_install is True
    assert opts.docker_group_add is True
    assert opts.docker_pull is True
    assert m_utils.confirm.call_count == 3

    # use_defaults set -> no prompt
    opts.use_defaults = True
    m_utils.confirm.reset_mock()
    m_utils.command_exists.return_value = False
    m_utils.is_docker_user.return_value = False
    m_utils.confirm.return_value = True
    opts.check_docker_opts()
    assert opts.docker_install is True
    assert opts.docker_group_add is True
    assert opts.docker_pull is True
    assert m_utils.confirm.call_count == 0

    # existing install -> only pull
    opts.use_defaults = False
    m_utils.confirm.reset_mock()
    m_utils.command_exists.return_value = True
    m_utils.is_docker_user.return_value = True
    m_utils.confirm.return_value = True
    opts.check_docker_opts()
    assert opts.docker_install is False
    assert opts.docker_group_add is False
    assert opts.docker_pull is True
    assert m_utils.confirm.call_count == 1