15
15
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16
16
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17
17
18
- import unittest
19
- import logging
18
+ import errno
20
19
import fileinput
21
-
22
- import os , shutil , errno , sys
23
-
20
+ import logging
21
+ import os
24
22
import pytest
23
+ import shutil
24
+ import sys
25
+ import unittest
26
+
25
27
from roundup import configuration
28
+ from roundup .backends import get_backend , have_backend
29
+ from roundup .hyperdb import DatabaseError
30
+
31
+ from .db_test_base import config
32
+
33
+ if not have_backend ('postgresql' ):
34
+ # FIX: workaround for a bug in pytest.mark.skip():
35
+ # https://github.com/pytest-dev/pytest/issues/568
36
+ from .pytest_patcher import mark_class
37
+ skip_postgresql = mark_class (pytest .mark .skip (
38
+ reason = 'Skipping PostgreSQL tests: backend not available' ))
39
+ else :
40
+ try :
41
+ from roundup .backends .back_postgresql import psycopg2 , db_command ,\
42
+ get_database_schema_names
43
+ db_command (config , 'select 1' )
44
+ skip_postgresql = lambda func , * args , ** kwargs : func
45
+ except ( DatabaseError ) as msg :
46
+ from .pytest_patcher import mark_class
47
+ skip_postgresql = mark_class (pytest .mark .skip (
48
+ reason = 'Skipping PostgreSQL tests: database not available' ))
49
+
26
50
27
51
try :
28
52
import xapian
@@ -802,7 +826,7 @@ def testInvalidIndexerLanguage_w_native_fts(self):
802
826
self .assertIn ("basque" , cm .exception .args [2 ])
803
827
804
828
@skip_redis
805
- def testLoadSessionDbRedis (self ):
829
+ def testLoadSessionDbRedisCompatible (self ):
806
830
""" run load to validate config """
807
831
808
832
config = configuration .CoreConfig ()
@@ -819,6 +843,10 @@ def testLoadSessionDbRedis(self):
819
843
820
844
config .validator (config .options )
821
845
846
+ @skip_redis
847
+ @skip_postgresql
848
+ def testLoadSessionDbRedisIncompatible (self ):
849
+ """ run load to validate config """
822
850
# incompatible pair
823
851
config .RDBMS_BACKEND = "postgresql"
824
852
config .SESSIONDB_BACKEND = "redis"
0 commit comments