Move unit and integration tests in-tree
This is mostly no-op, there are minor fixes because the tests directory was not included in pep8 and bandit checks. We'll now be checking tests with flake8. Tests were already included in the source tarball. When installing from pypi, this means tests will now be shipped as well. In binary packaging that is being working on, there will be separate packages for ara, docs and test. This makes this part slightly more straightforward. Change-Id: Ia8b7f8fc2a815d5e974d597b0d0d3c2b7a66220d
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import json
|
||||
import random
|
||||
|
||||
import ara.models as m
|
||||
@@ -1,4 +1,3 @@
|
||||
import random
|
||||
from flask.ext.testing import TestCase
|
||||
import pytest
|
||||
|
||||
@@ -186,7 +186,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res, zip(*sorted(six.iteritems(facts))))
|
||||
|
||||
def test_host_fact_non_existing_host(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.host.HostFacts(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -229,7 +229,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0][0], ctx['play'].id)
|
||||
|
||||
def test_play_list_non_existing_playbook(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.play.PlayList(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -249,7 +249,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0], ctx['play'].id)
|
||||
|
||||
def test_play_show_non_existing(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.play.PlayShow(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -282,7 +282,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0][0], ctx['playbook'].id)
|
||||
|
||||
def test_playbook_list_complete_with_no_complete(self):
|
||||
ctx = ansible_run(complete=False)
|
||||
ansible_run(complete=False)
|
||||
|
||||
cmd = ara.cli.playbook.PlaybookList(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -302,7 +302,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0][0], ctx['playbook'].id)
|
||||
|
||||
def test_playbook_list_incomplete_with_no_incomplete(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.playbook.PlaybookList(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -322,7 +322,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0], ctx['playbook'].id)
|
||||
|
||||
def test_playbook_show_non_existing(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.playbook.PlaybookShow(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -355,7 +355,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0][0], ctx['result'].id)
|
||||
|
||||
def test_result_list_non_existing_playbook(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.result.ResultList(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -375,7 +375,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0][0], ctx['result'].id)
|
||||
|
||||
def test_result_list_non_existing_play(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.result.ResultList(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -469,7 +469,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0][0], ctx['task'].id)
|
||||
|
||||
def test_task_list_non_existing_play(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.task.TaskList(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -489,7 +489,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0][0], ctx['task'].id)
|
||||
|
||||
def test_task_list_non_existing_playbook(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.task.TaskList(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -509,7 +509,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0], ctx['task'].id)
|
||||
|
||||
def test_task_show_non_existing(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.task.TaskShow(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -542,7 +542,7 @@ class TestCLI(TestCase):
|
||||
self.assertEqual(res[1][0], ctx['stats'].id)
|
||||
|
||||
def test_stats_show_non_existing(self):
|
||||
ctx = ansible_run()
|
||||
ansible_run()
|
||||
|
||||
cmd = ara.cli.stats.StatsShow(None, None)
|
||||
parser = cmd.get_parser('test')
|
||||
@@ -4,8 +4,6 @@ import ara.models as m
|
||||
import ara.utils as u
|
||||
import json
|
||||
|
||||
from mock import Mock
|
||||
|
||||
|
||||
class TestUtils(TestCase):
|
||||
'''Tests the utils module'''
|
||||
@@ -33,8 +33,8 @@ export ANSIBLE_LIBRARY="ara/plugins/modules"
|
||||
export ARA_DATABASE="sqlite:///${DATABASE}"
|
||||
|
||||
# Run test playbooks
|
||||
ansible-playbook -vv tests/integration/smoke.yml
|
||||
ansible-playbook -vv tests/integration/hosts.yml
|
||||
ansible-playbook -vv ara/tests/integration/smoke.yml
|
||||
ansible-playbook -vv ara/tests/integration/hosts.yml
|
||||
|
||||
# Run test commands
|
||||
pbid=$(ara playbook list -c ID -f value |head -n1)
|
||||
@@ -54,7 +54,7 @@ ara file show $(ara file list -b $pbid -c ID -f value|head -n1)
|
||||
ara generate ${BUILD_DIR} && tree ${BUILD_DIR}
|
||||
|
||||
# Database migration tests
|
||||
for test_db in $(ls tests/integration/databases/*.sqlite)
|
||||
for test_db in $(ls ara/tests/integration/databases/*.sqlite)
|
||||
do
|
||||
export ARA_DATABASE="sqlite:///${SCRIPT_DIR}/${test_db}"
|
||||
ara-manage db upgrade
|
||||
|
||||
6
tox.ini
6
tox.ini
@@ -19,17 +19,17 @@ commands = sphinx-build -W -b html doc/source doc/build/html
|
||||
[testenv:pep8]
|
||||
commands =
|
||||
flake8 ara
|
||||
bandit -r ara
|
||||
bandit -r ara -x ara/tests
|
||||
|
||||
[testenv:py27]
|
||||
commands =
|
||||
py.test tests/unit
|
||||
py.test ara/tests/unit
|
||||
passenv =
|
||||
HOME
|
||||
|
||||
[testenv:cover]
|
||||
commands =
|
||||
py.test --cov=ara --cov-report=html tests/unit
|
||||
py.test --cov=ara --cov-report=html ara/tests/unit
|
||||
passenv =
|
||||
HOME
|
||||
|
||||
|
||||
Reference in New Issue
Block a user