From c84288eaac56623b4d89024b1c5857cae2a4cd5d Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Tue, 3 May 2016 18:59:08 -0600 Subject: [PATCH] Set up basic testing framework with py.test We're just testing that the about route works at all. We aren't even testing that it does anything. But this represents wiring together a bunch of things to get tests working including configuration specifications, DB connections, table definitions, the app itself, etc --- conftest.py | 31 +++++++++++++++++++++++++++++++ pytest.ini | 3 +++ tests/api/test_about.py | 3 +++ 3 files changed, 37 insertions(+) create mode 100644 conftest.py create mode 100644 pytest.ini create mode 100644 tests/api/test_about.py diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..a44b544 --- /dev/null +++ b/conftest.py @@ -0,0 +1,31 @@ +import logging + +import pytest + +import vanth.config +import vanth.tables +from vanth.server import create_app + +LOGGER = logging.getLogger(__name__) + +def pytest_cmdline_main(): + logging.basicConfig() + logging.getLogger().setLevel(logging.DEBUG) + +@pytest.fixture(scope='session') +def tables(): + return vanth.tables + +@pytest.fixture +def app(configuration): + _app = create_app(configuration) + _app.config['TESTING'] = True + return _app + +@pytest.fixture(scope="session") +def db_connection_uri(configuration): + return configuration.db + +@pytest.fixture(scope='session') +def config_specification(): + return vanth.config.SPECIFICATION diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..d305d5d --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +norecursedirs = build ve node_modules +addopts=--tb=short diff --git a/tests/api/test_about.py b/tests/api/test_about.py new file mode 100644 index 0000000..b08e28f --- /dev/null +++ b/tests/api/test_about.py @@ -0,0 +1,3 @@ +def test_about(client): + response = client.get('/about/') + assert response.status_code == 200