Run inventory test during Jenkins lint check

Change-Id: I51ac381b516f7a71051c67270310591e4c09fdbe
This commit is contained in:
Travis Truman 2016-03-04 13:42:38 -05:00
parent c7f141dbab
commit e7060e421a
2 changed files with 10 additions and 11 deletions

View File

@ -8,12 +8,11 @@ import subprocess
import unittest
INV_DIR = '../playbooks/inventory'
INV_DIR = 'playbooks/inventory'
SCRIPT_FILENAME = 'dynamic_inventory.py'
INV_SCRIPT = path.join(INV_DIR, SCRIPT_FILENAME)
INV_SCRIPT = path.join(os.getcwd(), INV_DIR, SCRIPT_FILENAME)
# We'll use the test directory, and have tox do the cd command for us.
TARGET_DIR = path.join(os.getcwd(), 'inventory')
TARGET_DIR = path.join(os.getcwd(), 'tests', 'inventory')
# These files will be placed in TARGET_DIR by INV_SCRIPT.
# They should be cleaned up between each test.
@ -34,7 +33,7 @@ def cleanup():
def get_inventory():
"Return the inventory mapping in a dict."
try:
cmd = [INV_SCRIPT, '--file', TARGET_DIR]
cmd = [INV_SCRIPT, '--config', TARGET_DIR]
inventory_string = subprocess.check_output(cmd)
inventory = json.loads(inventory_string)
return inventory

12
tox.ini
View File

@ -1,7 +1,7 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = docs,linters,releasenotes,inventory
envlist = docs,linters,releasenotes
[testenv]
usedevelop = True
@ -100,6 +100,10 @@ commands =
--list-tasks \
{toxinidir}/playbooks/*.yml"
[testenv:inventory]
commands =
python {toxinidir}/tests/test_inventory.py
[testenv:linters]
deps =
{[testenv:pep8]deps}
@ -113,8 +117,4 @@ commands =
{[testenv:bashate]commands}
{[testenv:ansible-lint]commands}
{[testenv:ansible-syntax]commands}
[testenv:inventory]
changedir = {toxinidir}/tests
commands =
python test_inventory.py
{[testenv:inventory]commands}