Skip to content

Commit

Permalink
test: skip test requiring postgresql backend if not present
Browse files Browse the repository at this point in the history
  • Loading branch information
rouilj committed Apr 20, 2024
1 parent 7612c47 commit b1c8e53
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,38 @@
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

import unittest
import logging
import errno
import fileinput

import os, shutil, errno, sys

import logging
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

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'))


try:
import xapian
Expand Down Expand Up @@ -802,7 +826,7 @@ def testInvalidIndexerLanguage_w_native_fts(self):
self.assertIn("basque", cm.exception.args[2])

@skip_redis
def testLoadSessionDbRedis(self):
def testLoadSessionDbRedisCompatible(self):
""" run load to validate config """

config = configuration.CoreConfig()
Expand All @@ -819,6 +843,10 @@ def testLoadSessionDbRedis(self):

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"
Expand Down

0 comments on commit b1c8e53

Please sign in to comment.