diff --git a/test/test_automated_install.py b/test/test_automated_install.py index f6b5a87e..0810b63f 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -595,3 +595,80 @@ def test_os_check_passes(Pihole): ''') expected_stdout = 'Supported OS detected' assert expected_stdout in detectOS.stdout + + +def test_install_dependent_packages_no_errors(Pihole): + ''' + confirms all dependent packages are installed on a fresh build + ''' + # mock whiptail answers and ensure installer dependencies + mock_command('whiptail', {'*': ('', '0')}, Pihole) + # create configuration file + setup_var_file = 'cat < /etc/pihole/setupVars.conf\n' + for k, v in SETUPVARS.items(): + setup_var_file += "{}={}\n".format(k, v) + setup_var_file += "EOF\n" + Pihole.run(setup_var_file) + install = Pihole.run(''' + runUnattended=true + useUpdateVars=true + source /opt/pihole/basic-install.sh + runUnattended=true + useUpdateVars=true + distro_check + update_package_cache || exit 1 + install_dependent_packages "${INSTALLER_DEPS[@]}" + ''') + + assert install.rc == 0 + + +def test_install_dependent_packages_web_no_errors(Pihole): + ''' + confirms all dependent packages are installed on a fresh build + ''' + # mock whiptail answers and ensure installer dependencies + mock_command('whiptail', {'*': ('', '0')}, Pihole) + # mock systemctl to start lighttpd + mock_command_2( + 'systemctl', + { + 'enable lighttpd': ( + '', + '0' + ), + 'restart lighttpd': ( + '/etc/init.d/lighttpd restart', + '0' + ), + 'start lighttpd': ( + '/etc/init.d/lighttpd start', + '0' + ) + }, + Pihole + ) + # create configuration file + setup_var_file = 'cat < /etc/pihole/setupVars.conf\n' + for k, v in SETUPVARS.items(): + setup_var_file += "{}={}\n".format(k, v) + setup_var_file += "EOF\n" + Pihole.run(setup_var_file) + install = Pihole.run(''' + runUnattended=true + useUpdateVars=true + INSTALL_WEB_SERVER=true + source /opt/pihole/basic-install.sh + runUnattended=true + useUpdateVars=true + INSTALL_WEB_SERVER=true + distro_check + update_package_cache || exit 1 + dep_install_list=("${PIHOLE_DEPS[@]}") + if [[ "${INSTALL_WEB_SERVER}" == true ]]; then + dep_install_list+=("${PIHOLE_WEB_DEPS[@]}") + fi + install_dependent_packages "${dep_install_list[@]}" + ''') + + assert install.rc == 0