From bf417f50a4fc6e290b5ff762c607e6af4b5b5d1d Mon Sep 17 00:00:00 2001 From: Cristian Date: Tue, 7 Jul 2020 14:46:45 -0500 Subject: [PATCH] feat: Add bottle webserver to run along with tests --- setup.py | 1 + tests/conftest.py | 19 +++++++++++++++++++ tests/mock_server/__init__.py | 0 tests/mock_server/server.py | 8 ++++++++ 4 files changed, 28 insertions(+) create mode 100644 tests/conftest.py create mode 100644 tests/mock_server/__init__.py create mode 100644 tests/mock_server/server.py diff --git a/setup.py b/setup.py index 9ca39608..66112bfd 100755 --- a/setup.py +++ b/setup.py @@ -65,6 +65,7 @@ setuptools.setup( "sphinx-rtd-theme", "recommonmark", "pytest", + "bottle", ], # 'redis': ['redis', 'django-redis'], # 'pywb': ['pywb', 'redis'], diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..20128da7 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,19 @@ +from multiprocessing import Process + +import pytest +from .mock_server.server import start + +server_process = None + +@pytest.hookimpl +def pytest_sessionstart(session): + global server_process + server_process = Process(target=start) + server_process.start() + +@pytest.hookimpl +def pytest_sessionfinish(session): + if server_process is not None: + server_process.terminate() + server_process.join() + \ No newline at end of file diff --git a/tests/mock_server/__init__.py b/tests/mock_server/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/mock_server/server.py b/tests/mock_server/server.py new file mode 100644 index 00000000..da7ca5b2 --- /dev/null +++ b/tests/mock_server/server.py @@ -0,0 +1,8 @@ +from bottle import route, run + +@route('/') +def index(): + return "Hello" + +def start(): + run(host='localhost', port=8080) \ No newline at end of file