Mercurial > p > roundup > code
diff test/test_config.py @ 7900:011941fcb598
test: skip test requiring postgresql backend if not present
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 20 Apr 2024 16:27:23 -0400 |
| parents | be6cb2e0d471 |
| children | 6102ae426390 |
line wrap: on
line diff
--- a/test/test_config.py Sat Apr 20 15:54:54 2024 -0400 +++ b/test/test_config.py Sat Apr 20 16:27:23 2024 -0400 @@ -15,14 +15,38 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -import unittest +import errno +import fileinput import logging -import fileinput +import os +import pytest +import shutil +import sys +import unittest + +from roundup import configuration +from roundup.backends import get_backend, have_backend +from roundup.hyperdb import DatabaseError + +from .db_test_base import config -import os, shutil, errno, sys +if not have_backend('postgresql'): + # FIX: workaround for a bug in pytest.mark.skip(): + # https://github.com/pytest-dev/pytest/issues/568 + from .pytest_patcher import mark_class + skip_postgresql = mark_class(pytest.mark.skip( + reason='Skipping PostgreSQL tests: backend not available')) +else: + try: + from roundup.backends.back_postgresql import psycopg2, db_command,\ + get_database_schema_names + db_command(config, 'select 1') + skip_postgresql = lambda func, *args, **kwargs: func + except( DatabaseError ) as msg: + from .pytest_patcher import mark_class + skip_postgresql = mark_class(pytest.mark.skip( + reason='Skipping PostgreSQL tests: database not available')) -import pytest -from roundup import configuration try: import xapian @@ -802,7 +826,7 @@ self.assertIn("basque", cm.exception.args[2]) @skip_redis - def testLoadSessionDbRedis(self): + def testLoadSessionDbRedisCompatible(self): """ run load to validate config """ config = configuration.CoreConfig() @@ -819,6 +843,10 @@ config.validator(config.options) + @skip_redis + @skip_postgresql + def testLoadSessionDbRedisIncompatible(self): + """ run load to validate config """ # incompatible pair config.RDBMS_BACKEND = "postgresql" config.SESSIONDB_BACKEND = "redis"
