From 8ea323895accdc903aabaa2aa2dff16b0e4ec148 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Mon, 16 Apr 2018 07:53:39 -0400 Subject: [PATCH] fix conditional LDAP test fail Previously, if the main unit tests, test_common.py was run before running this test, it would fail. By clearing the cache at the start of the test, we make its behavior consistent and predictable no matter what other tests are also being ran, and the assertion is adjusted to match. --- awx/sso/tests/unit/test_ldap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awx/sso/tests/unit/test_ldap.py b/awx/sso/tests/unit/test_ldap.py index 0a50871650..f8ad8264d7 100644 --- a/awx/sso/tests/unit/test_ldap.py +++ b/awx/sso/tests/unit/test_ldap.py @@ -2,6 +2,7 @@ import ldap from awx.sso.backends import LDAPSettings from awx.sso.validators import validate_ldap_filter +from django.core.cache import cache def test_ldap_default_settings(mocker): @@ -13,11 +14,11 @@ def test_ldap_default_settings(mocker): def test_ldap_default_network_timeout(mocker): + cache.clear() # clearing cache avoids picking up stray default for OPT_REFERRALS from_db = mocker.Mock(**{'order_by.return_value': []}) with mocker.patch('awx.conf.models.Setting.objects.filter', return_value=from_db): settings = LDAPSettings() assert settings.CONNECTION_OPTIONS == { - ldap.OPT_REFERRALS: 0, ldap.OPT_NETWORK_TIMEOUT: 30 }