From 54bfc6fca9c763b280dc0301f6fce76b716afb43 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 23 2019 13:52:33 +0000 Subject: Add tox as a test executioner Signed-off-by: Pierre-Yves Chibon --- diff --git a/.gitignore b/.gitignore index 6cc902c..bc39beb 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ dist/ *~ .coverage alembic.ini +.tox/ +.pytest_cache/ diff --git a/tests/test_mdapi_data.py b/tests/test_mdapi_data.py index 58f7604..3dd140c 100644 --- a/tests/test_mdapi_data.py +++ b/tests/test_mdapi_data.py @@ -32,8 +32,10 @@ import subprocess import sys import tempfile +import mock import pytest from aiohttp import web +from sqlalchemy.exc import SQLAlchemyError sys.path.insert(0, os.path.join(os.path.dirname( os.path.abspath(__file__)), '..')) @@ -44,7 +46,7 @@ HERE = os.path.join(os.path.dirname(os.path.abspath(__file__))) TMPDIR = None -@pytest.fixture(scope="session", autouse=True) +@pytest.fixture(scope="module") def set_env(request): """ Collects the sqlite database from the mirror to have some data to test @@ -77,7 +79,7 @@ def tmpdir(): @pytest.fixture -def cli(tmpdir, loop, aiohttp_client): +def cli(set_env, tmpdir, loop, aiohttp_client): mdapi.CONFIG['DB_FOLDER'] = tmpdir app = web.Application() app = mdapi._set_routes(app) @@ -104,9 +106,9 @@ async def test_view_index_page(cli): async def test_view_branches(cli): resp = await cli.get('/branches') assert resp.status == 200 - assert '["dist-6E", "dist-6E-epel", "epel7", "f27", "f28", "f29", ' \ - '"koji", "rawhide", "src_dist-6E", "src_dist-6E-epel", ' \ - '"src_epel7", "src_rawhide"]' == await resp.text() + output = await resp.text() + assert 'src_rawhide' in output + assert 'rawhide' in output async def test_view_pkg_rawhide(cli): diff --git a/tests/test_mdapi_empty.py b/tests/test_mdapi_empty.py index 171a998..484cb8b 100644 --- a/tests/test_mdapi_empty.py +++ b/tests/test_mdapi_empty.py @@ -38,6 +38,7 @@ sys.path.insert(0, os.path.join(os.path.dirname( os.path.abspath(__file__)), '..')) import mdapi +import mdapi.lib HERE = os.path.join(os.path.dirname(os.path.abspath(__file__))) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..821a3c0 --- /dev/null +++ b/tox.ini @@ -0,0 +1,17 @@ +[tox] +envlist = py3 +skipsdist = True + +[testenv] +usedevelop = True +passenv = HOME +deps = + -rrequirements.txt + pytest + pytest-cov + pytest-aiohttp + mock +setenv = + PYTHONPATH={toxinidir} +commands = + py.test -s -vv --cov=mdapi {posargs}