From 51403fec50940132697b2fe54d7b41cb1a39a45e Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sat, 15 Mar 2014 11:06:29 +1100 Subject: [PATCH] TST: fail2ban-testcases to be able to be run on installed fail2ban --- fail2ban/tests/clientreadertestcase.py | 8 ++------ fail2ban/tests/databasetestcase.py | 5 ++++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/fail2ban/tests/clientreadertestcase.py b/fail2ban/tests/clientreadertestcase.py index 48261d11..0213263e 100644 --- a/fail2ban/tests/clientreadertestcase.py +++ b/fail2ban/tests/clientreadertestcase.py @@ -35,13 +35,9 @@ TEST_FILES_DIR = os.path.join(os.path.dirname(__file__), "files") if os.path.exists(os.path.join('config','fail2ban.conf')): CONFIG_DIR='config' else: - CONFIG_DIR=os.path.join('etc','fail2ban') - -IMPERFECT_CONFIG = os.path.join('fail2ban', 'tests','config') - - -IMPERFECT_CONFIG = os.path.join('fail2ban', 'tests','config') + CONFIG_DIR='/etc/fail2ban' +IMPERFECT_CONFIG = os.path.join(os.path.dirname(__file__), 'config') class ConfigReaderTest(unittest.TestCase): diff --git a/fail2ban/tests/databasetestcase.py b/fail2ban/tests/databasetestcase.py index 83a0ba5b..dfc26772 100644 --- a/fail2ban/tests/databasetestcase.py +++ b/fail2ban/tests/databasetestcase.py @@ -34,6 +34,8 @@ from ..server.mytime import MyTime from ..server.ticket import FailTicket from .dummyjail import DummyJail +TEST_FILES_DIR = os.path.join(os.path.dirname(__file__), "files") + class DatabaseTest(unittest.TestCase): def setUp(self): @@ -65,7 +67,8 @@ class DatabaseTest(unittest.TestCase): "Jail not retained in Db after disconnect reconnect.") def testUpdateDb(self): - shutil.copyfile('fail2ban/tests/files/database_v1.db', self.dbFilename) + shutil.copyfile( + os.path.join(TEST_FILES_DIR, 'database_v1.db'), self.dbFilename) self.db = Fail2BanDb(self.dbFilename) self.assertEqual(self.db.getJailNames(), set(['DummyJail #29162448 with 0 tickets'])) self.assertEqual(self.db.getLogPaths(), set(['/tmp/Fail2BanDb_pUlZJh.log']))