py.test now builds containers, travis py.test

* Instead of using the docker_dev, py.test builds and runs containers
* Travis-CI hopefully can run these same tests on PR/Merges now
This commit is contained in:
diginc 2016-07-18 10:44:55 -05:00
parent fae728415f
commit b41dd1bf8c
5 changed files with 39 additions and 18 deletions

View File

@ -1,12 +1,14 @@
sudo: required
language: python
python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
# does not have headers provided, please ask https://launchpad.net/~pypy/+archive/ppa
# maintainers to fix their pypy-dev package.
- "pypy"
# command to install dependencies
install:
- pip install -r requirements.txt
services:
- docker
before_install:
- docker pull diginc/pi-hole:alpine
- docker pull diginc/pi-hole:debian
script:
- docker build -f alpine.docker .
- docker build -f debian.docker .
script: py.test

1
autotest Executable file
View File

@ -0,0 +1 @@
py.test -f test/

0
test/__init__.py Normal file
View File

View File

@ -17,7 +17,7 @@ def TestinfraBackend(request):
def teardown():
check_output("docker rm -f %s", docker_id)
request.addfinalizer(teardown)
request.addfinalizer(teardown)
return testinfra.get_backend("docker://" + docker_id)
@ -26,7 +26,7 @@ def pytest_generate_tests(metafunc):
if "TestinfraBackend" in metafunc.fixturenames:
mark_args = getattr(metafunc.function, "docker_args", None)
docker_args = []
docker_args = []
if mark_args is not None:
docker_args = docker_args + list(mark_args.args)
@ -36,14 +36,14 @@ def pytest_generate_tests(metafunc):
images = mark_images.args
mark_cmd = getattr(metafunc.function, "docker_cmd", None)
command = 'tail -f /dev/null'
command = 'tail -f /dev/null'
if mark_cmd is not None:
command = " ".join(mark_cmd.args)
docker_run_args = []
for img in images:
docker_run_args.append('{} {} {}'.format(" ".join(docker_args),
img, command))
docker_run_args = []
for img in images:
docker_run_args.append('{} {} {}'.format(" ".join(docker_args),
img, command))
if getattr(metafunc.function, "persistent", None) is not None:
scope = "session"
else:

View File

@ -0,0 +1,18 @@
''' This file starts with 000 to make it run first '''
import pytest
import testinfra
run_local = testinfra.get_backend(
"local://"
).get_module("Command").run
@pytest.mark.parametrize("image,tag", [
( 'alpine.docker', 'diginc/pi-hole:alpine' ),
( 'debian.docker', 'diginc/pi-hole:debian' ),
])
def test_build_pihole_image(image, tag):
build_cmd = run_local('docker build -f {} -t {} .'.format(image, tag))
if build_cmd.rc != 0:
print build_cmd.stdout
print build_cmd.stderr
assert build_cmd.rc == 0