From f6006e09d5ba017749278216ab5958f63655d720 Mon Sep 17 00:00:00 2001 From: diginc Date: Sun, 6 Nov 2016 13:41:43 -0600 Subject: [PATCH] add test for pihole scripts, restartDNS first test --- test/test_pihole_scripts.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/test_pihole_scripts.py diff --git a/test/test_pihole_scripts.py b/test/test_pihole_scripts.py new file mode 100644 index 0000000..01cd1b6 --- /dev/null +++ b/test/test_pihole_scripts.py @@ -0,0 +1,17 @@ +import pytest + +RESTART_DNS_STDOUT = { + 'alpine': '', + 'debian': 'Restarting DNS forwarder and DHCP server: dnsmasq.\n' +} +def test_pihole_restartdns(RunningPiHole, Slow, persist_tag): + ''' ensure a new pid for dnsmasq appears and we have stdout as expected ''' + oldpid = RunningPiHole.run('pidof dnsmasq') + restartdns = RunningPiHole.run('pihole restartdns') + Slow(lambda: RunningPiHole.run('pgrep dnsmasq').rc == 0) + newpid = RunningPiHole.run('pidof dnsmasq') + for pid in [oldpid, newpid]: + assert pid != '' + assert oldpid != newpid + assert restartdns.rc == 0 + assert restartdns.stdout == RESTART_DNS_STDOUT[persist_tag]