Stub out dependency on subprocess in unit tests

Stub out the sheepdog Store dependency on subprocess communication
with collie.  This results in many unnecessary pipes being created
on POSIX systems.

For unit testing purposes, do not create the sheepdog store.  (There
are no unit tests for this functionality anyway.)

Change-Id: I54014a502891ae52bb567f3fae32e6ff0c74332a
This commit is contained in:
Brian Elliott 2013-07-19 00:08:37 +00:00
parent c92aa52576
commit d1adad0761
1 changed files with 10 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import stubout
from glance import store
from glance.store import location
from glance.store import sheepdog
from glance.tests import stubs
from glance.tests import utils as test_utils
@ -39,9 +40,17 @@ class StoreClearingUnitTest(test_utils.BaseTestCase):
super(StoreClearingUnitTest, self).setUp()
# Ensure stores + locations cleared
location.SCHEME_TO_CLS_MAP = {}
store.create_stores()
self._create_stores()
self.addCleanup(setattr, location, 'SCHEME_TO_CLS_MAP', dict())
def _create_stores(self):
"""Create known stores. Mock out sheepdog's subprocess dependency
on collie.
"""
self.stubs.Set(sheepdog.Store, 'configure_add', lambda x: None)
store.create_stores()
class IsolatedUnitTest(StoreClearingUnitTest):