diff test/test_config.py @ 6368:e3ed3ad9e795

issue2551125 Add indexer_lang test that runs if xapian not installed Test case for xapian not installed. Same test as testInvalidIndexerLanguage_xapian_missing except without magling sys.modules.
author John Rouillard <rouilj@ieee.org>
date Wed, 31 Mar 2021 09:19:03 -0400
parents 8a7de159d1a6
children 5c1db5d4baed
line wrap: on
line diff
--- a/test/test_config.py	Wed Mar 31 08:43:03 2021 -0400
+++ b/test/test_config.py	Wed Mar 31 09:19:03 2021 -0400
@@ -27,12 +27,17 @@
 try:
     import xapian
     skip_xapian = lambda func, *args, **kwargs: func
+    from .pytest_patcher import mark_class
+    include_no_xapian = mark_class(pytest.mark.skip(
+        "Skipping missing Xapian indexer tests: 'xapian' is installed"))
 except ImportError:
     # FIX: workaround for a bug in pytest.mark.skip():
     #   https://github.com/pytest-dev/pytest/issues/568
     from .pytest_patcher import mark_class
     skip_xapian = mark_class(pytest.mark.skip(
         "Skipping Xapian indexer tests: 'xapian' not installed"))
+    include_no_xapian = lambda func, *args, **kwargs: func
+    
 
 config = configuration.CoreConfig()
 config.DATABASE = "db"
@@ -406,6 +411,25 @@
         # look for supported language
         self.assertIn("english", cm.exception.args[2])
 
+    @include_no_xapian
+    def testInvalidIndexerLanguage_w_empty_no_xapian(self):
+        """ Test case for empty indexer if xapian really isn't installed
+
+            This should behave like testInvalidIndexerLanguage_xapian_missing
+            but without all the sys.modules mangling.
+        """
+        print("Testing when xapian is not installed")
+
+        # SETUP: set indexer_language value to an invalid value.
+        self.munge_configini(mods=[ ("indexer = ", ""),
+            ("indexer_language = ", "NO_LANG") ])
+
+        config = configuration.CoreConfig()
+
+        config.load(self.dirname)
+
+        self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG')
+
     def testInvalidIndexerLanguage_xapian_missing(self):
         """Using default path for indexers, make import of xapian
            fail and prevent exception from happening even though

Roundup Issue Tracker: http://roundup-tracker.org/