mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2025-12-20 02:18:51 +00:00
Added test to confirm updates are blocked
Signed-off-by: Adam Hill <adam@diginc.us>
This commit is contained in:
@@ -1,14 +1,18 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def start_cmd():
|
def start_cmd():
|
||||||
''' broken by default, required override '''
|
''' broken by default, required override '''
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def RunningPiHole(DockerPersist, Slow, persist_webserver, persist_tag, start_cmd):
|
def RunningPiHole(DockerPersist, Slow, persist_webserver, persist_tag, start_cmd):
|
||||||
''' Override the RunningPiHole to run and check for success of a
|
''' Override the RunningPiHole to run and check for success of a
|
||||||
pihole-FTL start based `pihole` script command '''
|
pihole-FTL start based `pihole` script command
|
||||||
|
|
||||||
|
Individual tests all must override start_cmd'''
|
||||||
#print DockerPersist.run('ps -ef').stdout
|
#print DockerPersist.run('ps -ef').stdout
|
||||||
assert DockerPersist.dig.run('ping -c 1 test_pihole').rc == 0
|
assert DockerPersist.dig.run('ping -c 1 test_pihole').rc == 0
|
||||||
Slow(lambda: DockerPersist.run('pgrep pihole-FTL').rc == 0)
|
Slow(lambda: DockerPersist.run('pgrep pihole-FTL').rc == 0)
|
||||||
@@ -26,16 +30,12 @@ def RunningPiHole(DockerPersist, Slow, persist_webserver, persist_tag, start_cmd
|
|||||||
DockerPersist.cmd = cmd
|
DockerPersist.cmd = cmd
|
||||||
return DockerPersist
|
return DockerPersist
|
||||||
|
|
||||||
@pytest.mark.parametrize('start_cmd', ['start_cmd'])
|
|
||||||
def test_pihole_start_cmd(RunningPiHole, start_cmd, persist_tag):
|
|
||||||
''' the start_cmd tests are all built into the RunningPiHole fixture in this file '''
|
|
||||||
assert RunningPiHole.cmd.stdout == START_DNS_STDOUT[persist_tag]
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('start_cmd,hostname,expected_ip, expected_messages', [
|
@pytest.mark.parametrize('start_cmd,hostname,expected_ip, expected_messages', [
|
||||||
('enable', 'pi.hole', '127.0.0.1', ['Enabling blocking','Pi-hole Enabled']),
|
('enable', 'pi.hole', '127.0.0.1', ['Enabling blocking','Pi-hole Enabled']),
|
||||||
('disable', 'pi.hole', '127.0.0.1', ['Disabling blocking','Pi-hole Disabled']),
|
('disable', 'pi.hole', '127.0.0.1', ['Disabling blocking','Pi-hole Disabled']),
|
||||||
])
|
])
|
||||||
def test_pihole_start_cmd(RunningPiHole, Dig, persist_tag, start_cmd, hostname, expected_ip, expected_messages):
|
def test_pihole_enable_disable_command(RunningPiHole, Dig, persist_tag, start_cmd, hostname, expected_ip, expected_messages):
|
||||||
''' the start_cmd tests are all built into the RunningPiHole fixture in this file '''
|
''' the start_cmd tests are all built into the RunningPiHole fixture in this file '''
|
||||||
dig_cmd = "dig +time=1 +noall +answer {} @test_pihole".format(hostname)
|
dig_cmd = "dig +time=1 +noall +answer {} @test_pihole".format(hostname)
|
||||||
lookup = RunningPiHole.dig.run(dig_cmd)
|
lookup = RunningPiHole.dig.run(dig_cmd)
|
||||||
@@ -45,3 +45,10 @@ def test_pihole_start_cmd(RunningPiHole, Dig, persist_tag, start_cmd, hostname,
|
|||||||
|
|
||||||
for part_of_output in expected_messages:
|
for part_of_output in expected_messages:
|
||||||
assert part_of_output in RunningPiHole.cmd.stdout
|
assert part_of_output in RunningPiHole.cmd.stdout
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('start_cmd,expected_message', [
|
||||||
|
('-up', 'Function not supported in Docker images')
|
||||||
|
])
|
||||||
|
def test_pihole_update_command(RunningPiHole, start_cmd, expected_message):
|
||||||
|
assert RunningPiHole.cmd.stdout.strip() == expected_message
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user