From 0e29aac9b16a3bb2b1f6901cd1f148fb5be5a354 Mon Sep 17 00:00:00 2001 From: Rajat Gupta <35985127+rjt-gupta@users.noreply.github.com> Date: Mon, 10 Jun 2019 21:47:58 +0530 Subject: [PATCH] bug fix (#330) Limit scope of test to prevent changes in tests running after it --- tanner/tests/test_api.py | 1 + tanner/tests/test_config.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tanner/tests/test_api.py b/tanner/tests/test_api.py index e588709a..4d151715 100644 --- a/tanner/tests/test_api.py +++ b/tanner/tests/test_api.py @@ -342,6 +342,7 @@ def test_apply_filter_end_time_false(self): def tearDown(self): async def close(): + await self.redis_client.flushall() self.redis_client.close() await self.redis_client.wait_closed() diff --git a/tanner/tests/test_config.py b/tanner/tests/test_config.py index b075c0a8..b862c9f4 100644 --- a/tanner/tests/test_config.py +++ b/tanner/tests/test_config.py @@ -2,10 +2,11 @@ import os import unittest +from unittest import mock from tanner import config -class TestCongif(unittest.TestCase): +class TestConfig(unittest.TestCase): def setUp(self): config.TannerConfig.config = None self.d = { @@ -15,7 +16,7 @@ def setUp(self): 'WEB': {'host': '0.0.0.0', 'port': '9001'}, 'API': {'host': '0.0.0.0', 'port': '9002'}, 'PHPOX': {'host': '0.0.0.0', 'port': '8088'}, - 'REDIS': {'host': 'localhost', 'port': '1337', 'poolsize': '40', 'timeout': '5'}, + 'REDIS': {'host': 'localhost', 'port': '6379', 'poolsize': '80', 'timeout': '5'}, 'EMULATORS': {'root_dir': '/opt/tanner'}, 'EMULATOR_ENABLED': {'sqli': 'True', 'rfi': 'True', 'lfi': 'True', 'xss': 'True', 'cmd_exec': 'True'}, 'SQLI': {'type': 'SQLITE', 'db_name': 'user_tanner_db', 'host': 'localhost', 'user': 'user_name', @@ -41,7 +42,8 @@ def setUp(self): self.invalid_config_path = '/random/random_name' - def test_set_config_when_file_exists(self): + @mock.patch('tanner.tests.test_config.config') + def test_set_config_when_file_exists(self, m): config.TannerConfig.set_config(self.valid_config_path) self.assertIsNotNone(config.TannerConfig.config)