aodh/ceilometer
ZhiQiang Fan 59e647f82c Avoid reading real config files in unit test
When we call oslo.config.cfg.CONF(), it will do basic setup and
search configuration files under certain directories, by default,
they are [/etc, /etc/ceilometer, ~/, ~/.ceilometer]. However, we
should avoid such behaviour when we run unit test code, because that
if the system has run devstack or installed ceilometer services,
then /etc/ceilometer/ceilometer.conf will exist, then unit test result
can be different.

So we should mock the default searching directories of cfg in the
begining of all unit tests, which will call cfg.CONF() at somewhere
during the test. The best place to mock the default directories
can be ceilometer.test.base.BaseTestCase, which should be used as
parent class of all other test classes.

Note: since this patch sets default searching directory to
{repo}/etc/ceilometer, you can run the unit test with different settings
which are set in etc/ceilometer/ceilometer.conf (not tracked by git).

Note: mock.patch.stopall has compatibility problem with oslo.fixture,
so this patch slightly refactors the
tests.compute.pollsters.base.TestPollsterBase.setUp method.

Change-Id: I533ffb2ba2c9be0223cecbcf04176312e4a96369
Closes-Bug: #1328550
2014-06-18 12:17:23 +08:00
..
alarm Separate alarm storage models from other models 2014-06-17 17:30:54 +02:00
api Separate alarm storage models from other models 2014-06-17 17:30:54 +02:00
central Merge "Skipping central agent pollster when keystone not available" 2014-06-10 14:09:30 +00:00
compute Merge "Remove (c) and remove unnecessary encoding lines" 2014-06-10 10:14:34 +00:00
dispatcher remove default=None for config options 2014-06-11 21:32:40 +08:00
energy Skipping central agent pollster when keystone not available 2014-06-10 16:20:29 +08:00
event Fix list of modules not included in auto-gen docs 2014-06-16 09:00:15 +02:00
hardware Merge "Use TYPE_GAUGE rather than TYPE_CUMULATIVE" 2014-06-12 20:23:13 +00:00
image Merge "Skipping central agent pollster when keystone not available" 2014-06-10 14:09:30 +00:00
locale Remove all mostly untranslated PO files 2014-05-22 09:02:36 +02:00
network Fix list of modules not included in auto-gen docs 2014-06-16 09:00:15 +02:00
objectstore Iterates swift response earlier to get the correct status 2014-06-17 14:21:36 +00:00
openstack Fix Sphinx directive name in session.py 2014-06-16 09:00:20 +02:00
orchestration Replace oslo.rpc by oslo.messaging 2014-04-14 11:56:56 +02:00
publisher Merge "Fix list of modules not included in auto-gen docs" 2014-06-17 10:31:34 +00:00
storage Separate alarm storage models from other models 2014-06-17 17:30:54 +02:00
tests Avoid reading real config files in unit test 2014-06-18 12:17:23 +08:00
transformer Remove (c) and remove unnecessary encoding lines 2014-05-31 13:02:21 +02:00
volume Remove (c) and remove unnecessary encoding lines 2014-05-31 13:02:21 +02:00
__init__.py Empty files should no longer contain copyright 2013-12-24 20:19:04 +08:00
agent.py Merge "Skipping central agent pollster when keystone not available" 2014-06-10 14:09:30 +00:00
cli.py remove default=None for config options 2014-06-11 21:32:40 +08:00
collector.py Don't keep a single global TRANSPORT object 2014-06-16 10:31:13 +02:00
messaging.py Fix messaging.get_transport caching 2014-06-17 11:38:11 +02:00
middleware.py Remove (c) and remove unnecessary encoding lines 2014-05-31 13:02:21 +02:00
neutron_client.py Metering LoadBalancer as a Service 2014-06-09 15:29:52 -07:00
notification.py Don't keep a single global TRANSPORT object 2014-06-16 10:31:13 +02:00
notifier.py Remove (c) and remove unnecessary encoding lines 2014-05-31 13:02:21 +02:00
nova_client.py Merge "Adds caches for image and flavor in compute agent" 2014-06-12 20:19:11 +00:00
pipeline.py Remove low-value logging from publication codepath 2014-06-10 17:23:00 +01:00
plugin.py Remove (c) and remove unnecessary encoding lines 2014-05-31 13:02:21 +02:00
sample.py Remove (c) and remove unnecessary encoding lines 2014-05-31 13:02:21 +02:00
service.py Remove (c) and remove unnecessary encoding lines 2014-05-31 13:02:21 +02:00
utils.py replaced unicode() with six.text_type() 2014-05-27 12:56:13 +02:00