Strip out no longer relevant tests/test fixtures (persist_docker, for example has not been used in a long time) , begin building test library from ground up.

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner
2023-07-24 18:06:43 +01:00
parent 6b5332be47
commit 3208c4042d
3 changed files with 11 additions and 430 deletions

View File

@@ -42,7 +42,7 @@ def args_volumes():
@pytest.fixture()
def args_env():
return '-e FTLCONF_LOCAL_IPV4="127.0.0.1"'
return '-e TZ="Europe/London"'
@pytest.fixture()
@@ -87,33 +87,6 @@ def docker(request, test_args, args, image, cmd, entrypoint):
return docker_generic(request, test_args, args, image, cmd, entrypoint)
@pytest.fixture(scope="module")
def docker_persist(
request,
persist_test_args,
persist_args,
persist_image,
persist_cmd,
persist_entrypoint,
dig,
):
"""
Persistent Docker container for multiple tests, instead of stopping container after one test
Uses DUP'd module scoped fixtures because smaller scoped fixtures won't mix with module scope
"""
persistent_container = docker_generic(
request,
persist_test_args,
persist_args,
persist_image,
persist_cmd,
persist_entrypoint,
)
""" attach a dig container for lookups """
persistent_container.dig = dig(persistent_container.id)
return persistent_container
@pytest.fixture
def entrypoint():
return ""
@@ -129,12 +102,6 @@ def tag(version):
return "{}".format(version)
@pytest.fixture
def webserver(tag):
"""TODO: this is obvious without alpine+nginx as the alternative, remove fixture, hard code lighttpd in tests?"""
return "lighttpd"
@pytest.fixture()
def image(tag):
image = "pihole"
@@ -146,64 +113,6 @@ def cmd():
return TAIL_DEV_NULL
@pytest.fixture(scope="module")
def persist_version():
return version
@pytest.fixture(scope="module")
def persist_args_dns():
return "--dns 127.0.0.1 --dns 1.1.1.1"
@pytest.fixture(scope="module")
def persist_args_volumes():
return "-v /dev/null:/etc/pihole/adlists.list"
@pytest.fixture(scope="module")
def persist_args_env():
return '-e ServerIP="127.0.0.1"'
@pytest.fixture(scope="module")
def persist_args(persist_args_volumes, persist_args_env):
return "{} {}".format(persist_args_volumes, persist_args_env)
@pytest.fixture(scope="module")
def persist_test_args():
"""test override fixture to provide arguments separate from our core args"""
return ""
@pytest.fixture(scope="module")
def persist_tag(persist_version):
return "{}".format(persist_version)
@pytest.fixture(scope="module")
def persist_webserver(persist_tag):
"""TODO: this is obvious without alpine+nginx as the alternative, remove fixture, hard code lighttpd in tests?"""
return "lighttpd"
@pytest.fixture(scope="module")
def persist_image(persist_tag):
image = "pihole"
return "{}:{}".format(image, persist_tag)
@pytest.fixture(scope="module")
def persist_cmd():
return TAIL_DEV_NULL
@pytest.fixture(scope="module")
def persist_entrypoint():
return ""
@pytest.fixture
def slow():
"""
@@ -225,26 +134,3 @@ def slow():
return
return _slow
@pytest.fixture(scope="module")
def dig():
"""separate container to link to pi-hole and perform lookups"""
""" a docker pull is faster than running an install of dnsutils """
def _dig(docker_id):
args = "--link {}:test_pihole".format(docker_id)
image = "azukiapp/dig"
cmd = TAIL_DEV_NULL
dig_container = docker_generic(request, "", args, image, cmd, "")
return dig_container
return _dig
@pytest.fixture
def running_pihole(docker_persist, slow, persist_webserver):
"""Persist a fully started docker-pi-hole to help speed up subsequent tests"""
slow(lambda: docker_persist.run("pgrep pihole-FTL").rc == 0)
slow(lambda: docker_persist.run("pgrep lighttpd").rc == 0)
return docker_persist