Clean up a couple hand-rolled mocks.
Change-Id: I6582985990e8b5e3a0c65bce5d3bb1e39d58dfb9
This commit is contained in:
parent
1da1bfb381
commit
9c97c80b26
@ -212,18 +212,10 @@ class TestRing(TestRingBase):
|
||||
self.assertEqual(self.ring.reload_time, self.intended_reload_time)
|
||||
self.assertEqual(self.ring.serialized_path, self.testgz)
|
||||
# test invalid endcap
|
||||
_orig_hash_path_suffix = utils.HASH_PATH_SUFFIX
|
||||
_orig_hash_path_prefix = utils.HASH_PATH_PREFIX
|
||||
_orig_swift_conf_file = utils.SWIFT_CONF_FILE
|
||||
try:
|
||||
utils.HASH_PATH_SUFFIX = ''
|
||||
utils.HASH_PATH_PREFIX = ''
|
||||
utils.SWIFT_CONF_FILE = ''
|
||||
with mock.patch.object(utils, 'HASH_PATH_SUFFIX', ''), \
|
||||
mock.patch.object(utils, 'HASH_PATH_PREFIX', ''), \
|
||||
mock.patch.object(utils, 'SWIFT_CONF_FILE', ''):
|
||||
self.assertRaises(SystemExit, ring.Ring, self.testdir, 'whatever')
|
||||
finally:
|
||||
utils.HASH_PATH_SUFFIX = _orig_hash_path_suffix
|
||||
utils.HASH_PATH_PREFIX = _orig_hash_path_prefix
|
||||
utils.SWIFT_CONF_FILE = _orig_swift_conf_file
|
||||
|
||||
def test_has_changed(self):
|
||||
self.assertFalse(self.ring.has_changed())
|
||||
|
@ -98,9 +98,8 @@ class TestBufferedHTTP(unittest.TestCase):
|
||||
raise Exception(err)
|
||||
|
||||
def test_nonstr_header_values(self):
|
||||
origHTTPSConnection = bufferedhttp.HTTPSConnection
|
||||
bufferedhttp.HTTPSConnection = MockHTTPSConnection
|
||||
try:
|
||||
with mock.patch('swift.common.bufferedhttp.HTTPSConnection',
|
||||
MockHTTPSConnection):
|
||||
bufferedhttp.http_connect(
|
||||
'127.0.0.1', 8080, 'sda', 1, 'GET', '/',
|
||||
headers={'x-one': '1', 'x-two': 2, 'x-three': 3.0,
|
||||
@ -109,8 +108,6 @@ class TestBufferedHTTP(unittest.TestCase):
|
||||
'127.0.0.1', 8080, 'GET', '/',
|
||||
headers={'x-one': '1', 'x-two': 2, 'x-three': 3.0,
|
||||
'x-four': {'crazy': 'value'}}, ssl=True)
|
||||
finally:
|
||||
bufferedhttp.HTTPSConnection = origHTTPSConnection
|
||||
|
||||
def test_unicode_values(self):
|
||||
with mock.patch('swift.common.bufferedhttp.HTTPSConnection',
|
||||
|
@ -1503,8 +1503,8 @@ class TestUtils(unittest.TestCase):
|
||||
syslog_handler_catcher.LOG_LOCAL0 = orig_sysloghandler.LOG_LOCAL0
|
||||
syslog_handler_catcher.LOG_LOCAL3 = orig_sysloghandler.LOG_LOCAL3
|
||||
|
||||
try:
|
||||
utils.ThreadSafeSysLogHandler = syslog_handler_catcher
|
||||
with mock.patch.object(utils, 'ThreadSafeSysLogHandler',
|
||||
syslog_handler_catcher):
|
||||
utils.get_logger({
|
||||
'log_facility': 'LOG_LOCAL3',
|
||||
}, 'server', log_route='server')
|
||||
@ -1553,8 +1553,6 @@ class TestUtils(unittest.TestCase):
|
||||
((), {'address': ('syslog.funtimes.com', 2123),
|
||||
'facility': orig_sysloghandler.LOG_LOCAL0})],
|
||||
syslog_handler_args)
|
||||
finally:
|
||||
utils.ThreadSafeSysLogHandler = orig_sysloghandler
|
||||
|
||||
@reset_logger_state
|
||||
def test_clean_logger_exception(self):
|
||||
@ -2977,8 +2975,7 @@ cluster_dfw1 = http://dfw1.host/v1/
|
||||
self.last_call[-1] = self.last_call[-1].value
|
||||
return 0
|
||||
|
||||
orig__sys_fallocate = utils._sys_fallocate
|
||||
try:
|
||||
with patch.object(utils, '_sys_fallocate', FallocateWrapper()):
|
||||
utils._sys_fallocate = FallocateWrapper()
|
||||
# Ensure fallocate calls _sys_fallocate even with 0 bytes
|
||||
utils._sys_fallocate.last_call = None
|
||||
@ -3000,8 +2997,6 @@ cluster_dfw1 = http://dfw1.host/v1/
|
||||
utils.fallocate(1234, 10 * 1024 * 1024 * 1024)
|
||||
self.assertEqual(utils._sys_fallocate.last_call,
|
||||
[1234, 1, 0, 10 * 1024 * 1024 * 1024])
|
||||
finally:
|
||||
utils._sys_fallocate = orig__sys_fallocate
|
||||
|
||||
def test_generate_trans_id(self):
|
||||
fake_time = 1366428370.5163341
|
||||
|
Loading…
Reference in New Issue
Block a user