add test case for installation of dependencies for installer, core and web

Signed-off-by: pvogt09 <50047961+pvogt09@users.noreply.github.com>
This commit is contained in:
pvogt09 2020-03-17 20:15:16 +01:00
parent fec1595183
commit 60a4814ac1

View file

@ -595,3 +595,80 @@ def test_os_check_passes(Pihole):
''') ''')
expected_stdout = 'Supported OS detected' expected_stdout = 'Supported OS detected'
assert expected_stdout in detectOS.stdout 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 <<EOF> /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 <<EOF> /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