diff --git a/deckhand/tests/unit/base.py b/deckhand/tests/unit/base.py index 5e9e7f9f..fec6514a 100644 --- a/deckhand/tests/unit/base.py +++ b/deckhand/tests/unit/base.py @@ -105,8 +105,10 @@ class DeckhandWithDBTestCase(DeckhandTestCase): def setUp(self): super(DeckhandWithDBTestCase, self).setUp() + if 'PIFPAF_URL' not in os.environ: + raise RuntimeError('Unit tests must be run using `pifpaf run ' + 'postgresql`.') self.override_config( - 'connection', os.environ.get('DATABASE_URL', 'sqlite://'), - group='database') + 'connection', os.environ['PIFPAF_URL'], group='database') db_api.setup_db() self.addCleanup(db_api.drop_db) diff --git a/test-requirements.txt b/test-requirements.txt index 29ab492e..45e0ed13 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -16,6 +16,7 @@ testtools>=1.4.0 # MIT bandit>=1.1.0 # Apache-2.0 gabbi==1.35.1 pytest-html==1.16.0 +pifpaf==2.0.0 # NOTE(fmontei): The requirement below is only included because readthedocs # depends on it to work, since it runs pip install -rtest-requirements.txt. diff --git a/tools/functional-tests.sh b/tools/functional-tests.sh index a32600ce..5833b7e5 100755 --- a/tools/functional-tests.sh +++ b/tools/functional-tests.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# Script intended for running Deckhand functional tests via gabbi. Requires +# Docker CE (at least) to run. + # Meant for capturing output of Deckhand image. This requires that logging # in the image be set up to pipe everything out to stdout/stderr. STDOUT=$(mktemp) diff --git a/tools/unit-tests.sh b/tools/unit-tests.sh index 92836f69..cf710c6e 100755 --- a/tools/unit-tests.sh +++ b/tools/unit-tests.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash # Script for setting up temporary PostgreSQL database for testing unit tests -# against. +# against. Requires Docker CE (at least) to be executed. Fallback in case +# `pifpaf` fails. function cleanup { sudo docker stop $POSTGRES_ID diff --git a/tox.ini b/tox.ini index 702e9a2d..4e1342e3 100644 --- a/tox.ini +++ b/tox.ini @@ -21,12 +21,12 @@ commands = [testenv:py27] commands = {[testenv]commands} - {toxinidir}/tools/unit-tests.sh '{posargs}' + pifpaf run postgresql -- '{toxinidir}'/tools/pretty_tox.sh '--concurrency=1 {posargs}' [testenv:py35] commands = {[testenv]commands} - {toxinidir}/tools/unit-tests.sh '{posargs}' + pifpaf run postgresql -- '{toxinidir}'/tools/pretty_tox.sh '--concurrency=1 {posargs}' [testenv:functional] usedevelop = True