Add unit tests for doctor's caching symptoms

Currently there are no unit tests for any of doctors symptoms. This
patch is only adding unit tests for the caching symptoms and more
will be released for each symptom group in doctor.

Change-Id: I177ef91206bcad095be06b0607c04c1547994146
Partial-Bug: #1641621
This commit is contained in:
“Richard 2016-12-02 17:07:37 +00:00 committed by Steve Martinelli
parent feeab95844
commit bb8be1ec88

View File

@ -25,6 +25,7 @@ from six.moves import range
from testtools import matchers
from keystone.cmd import cli
from keystone.cmd.doctor import caching
from keystone.common import dependency
from keystone.common.sql import upgrades
import keystone.conf
@ -710,3 +711,50 @@ class CliDomainConfigUploadNothing(unit.BaseTestCase):
CONF.identity.domain_config_dir)
self.assertThat(self.logging.output,
matchers.Contains(expected_msg))
class DoctorTestCase(unit.TestCase):
def test_symptom_caching_disabled(self):
# Success Case: Caching enabled and debug disabled
self.config_fixture.config(group='cache', enabled=False)
self.config_fixture.config(debug=False)
self.assertTrue(caching.symptom_caching_disabled())
# Failure Case 1: Caching disabled and debug enabled
self.config_fixture.config(group='cache', enabled=False)
self.config_fixture.config(debug=True)
self.assertFalse(caching.symptom_caching_disabled())
# Failure Case 2: Caching enabled and debug enabled
self.config_fixture.config(group='cache', enabled=True)
self.config_fixture.config(debug=True)
self.assertFalse(caching.symptom_caching_disabled())
# Failure Case 3: Caching enabled and debug disabled
self.config_fixture.config(group='cache', enabled=True)
self.config_fixture.config(debug=False)
self.assertFalse(caching.symptom_caching_disabled())
def test_caching_symptom_caching_enabled_without_a_backend(self):
# Success Case: Caching enabled and backend configured
self.config_fixture.config(group='cache', enabled=True)
self.config_fixture.config(group='cache', backend='dogpile.cache.null')
self.assertTrue(caching.symptom_caching_enabled_without_a_backend())
# Failure Case 1: Caching disabled and backend not configured
self.config_fixture.config(group='cache', enabled=False)
self.config_fixture.config(group='cache', backend='dogpile.cache.null')
self.assertFalse(caching.symptom_caching_enabled_without_a_backend())
# Failure Case 2: Caching disabled and backend configured
self.config_fixture.config(group='cache', enabled=False)
self.config_fixture.config(group='cache',
backend='dogpile.cache.memory')
self.assertFalse(caching.symptom_caching_enabled_without_a_backend())
# Failure Case 3: Caching enabled and backend configured
self.config_fixture.config(group='cache', enabled=True)
self.config_fixture.config(group='cache',
backend='dogpile.cache.memory')
self.assertFalse(caching.symptom_caching_enabled_without_a_backend())