Make unit tests not require /etc/swift/*.ring.gz files

This commit is contained in:
gholt 2010-07-13 14:23:39 -07:00
parent b072b61cdd
commit 7b38b9a19a
2 changed files with 16 additions and 16 deletions

View File

@ -934,7 +934,8 @@ class BaseApplication(object):
log_name = 'base_application'
def __init__(self, conf, memcache, logger=None):
def __init__(self, conf, memcache, logger=None, account_ring=None,
container_ring=None, object_ring=None):
if logger:
self.logger = logger
else:
@ -961,10 +962,12 @@ class BaseApplication(object):
int(conf.get('recheck_account_existence', 60))
self.resellers_conf = ConfigParser()
self.resellers_conf.read(os.path.join(swift_dir, 'resellers.conf'))
self.object_ring = Ring(os.path.join(swift_dir, 'object.ring.gz'))
self.container_ring = \
self.object_ring = object_ring or \
Ring(os.path.join(swift_dir, 'object.ring.gz'))
self.container_ring = container_ring or \
Ring(os.path.join(swift_dir, 'container.ring.gz'))
self.account_ring = Ring(os.path.join(swift_dir, 'account.ring.gz'))
self.account_ring = account_ring or \
Ring(os.path.join(swift_dir, 'account.ring.gz'))
self.memcache = memcache
self.rate_limit = float(conf.get('rate_limit', 20000.0))
self.account_rate_limit = float(conf.get('account_rate_limit', 200.0))

View File

@ -191,10 +191,9 @@ def save_globals():
class TestObjectController(unittest.TestCase):
def setUp(self):
self.app = proxy_server.Application(None, FakeMemcache())
self.app.object_ring = FakeRing()
self.app.container_ring = FakeRing()
self.app.account_ring = FakeRing()
self.app = proxy_server.Application(None, FakeMemcache(),
account_ring=FakeRing(), container_ring=FakeRing(),
object_ring=FakeRing())
def assert_status_map(self, method, statuses, expected, raise_exc=False):
with save_globals():
@ -1447,10 +1446,9 @@ class TestContainerController(unittest.TestCase):
"Test swift.proxy_server.ContainerController"
def setUp(self):
self.app = proxy_server.Application(None, FakeMemcache())
self.app.object_ring = FakeRing()
self.app.container_ring = FakeRing()
self.app.account_ring = FakeRing()
self.app = proxy_server.Application(None, FakeMemcache(),
account_ring=FakeRing(), container_ring=FakeRing(),
object_ring=FakeRing())
def assert_status_map(self, method, statuses, expected, raise_exc=False, missing_container=False):
with save_globals():
@ -1635,10 +1633,9 @@ class TestContainerController(unittest.TestCase):
class TestAccountController(unittest.TestCase):
def setUp(self):
self.app = proxy_server.Application(None, FakeMemcache())
self.app.object_ring = FakeRing()
self.app.container_ring = FakeRing()
self.app.account_ring = FakeRing()
self.app = proxy_server.Application(None, FakeMemcache(),
account_ring=FakeRing(), container_ring=FakeRing(),
object_ring=FakeRing)
def assert_status_map(self, method, statuses, expected):
with save_globals():