From 906eb98d8e3df73a004a150012eb355296ebbee4 Mon Sep 17 00:00:00 2001 From: chris meyers Date: Tue, 16 Oct 2018 10:45:24 -0400 Subject: [PATCH] fixes dispatcher test that inadvertently access db * Logger inadvertently triggered by dispatcher tests that do not need DB access. Mock settings to sidestep DB access. --- awx/main/tests/functional/conftest.py | 6 ++++++ awx/main/tests/functional/test_dispatch.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/awx/main/tests/functional/conftest.py b/awx/main/tests/functional/conftest.py index 30adb3cb66..a3e6199137 100644 --- a/awx/main/tests/functional/conftest.py +++ b/awx/main/tests/functional/conftest.py @@ -8,6 +8,7 @@ import tempfile import shutil from datetime import timedelta from six.moves import xrange +from mock import PropertyMock # Django from django.core.urlresolvers import resolve @@ -752,3 +753,8 @@ def sqlite_copy_expert(request): request.addfinalizer(lambda: delattr(SQLiteCursorWrapper, 'copy_expert')) return path + +@pytest.fixture +def disable_database_settings(mocker): + m = mocker.patch('awx.conf.settings.SettingsWrapper.all_supported_settings', new_callable=PropertyMock) + m.return_value = [] diff --git a/awx/main/tests/functional/test_dispatch.py b/awx/main/tests/functional/test_dispatch.py index 349d997e8f..b7dc158a9b 100644 --- a/awx/main/tests/functional/test_dispatch.py +++ b/awx/main/tests/functional/test_dispatch.py @@ -55,6 +55,7 @@ class SlowResultWriter(BaseWorker): super(SlowResultWriter, self).perform_work(body, result_queue) +@pytest.mark.usefixtures("disable_database_settings") class TestPoolWorker: def setup_method(self, test_method): @@ -247,6 +248,7 @@ class TestAutoScaling: assert len(self.pool) == 2 +@pytest.mark.usefixtures("disable_database_settings") class TestTaskDispatcher: @property