From e7060e421ad7696d3ac377a277508b3546fcc29f Mon Sep 17 00:00:00 2001 From: Travis Truman Date: Fri, 4 Mar 2016 13:42:38 -0500 Subject: [PATCH] Run inventory test during Jenkins lint check Change-Id: I51ac381b516f7a71051c67270310591e4c09fdbe --- tests/test_inventory.py | 9 ++++----- tox.ini | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/tests/test_inventory.py b/tests/test_inventory.py index 50195e31d0..9b98498138 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -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 diff --git a/tox.ini b/tox.ini index 13d6cb7384..a154e148f8 100644 --- a/tox.ini +++ b/tox.ini @@ -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} \ No newline at end of file