Replace 'assertTrue(a not in b)' with 'assertNotIn(a, b)'
trivialfix Change-Id: I416831c8ad92f8445bc8d9560040a5ebf5c90702
This commit is contained in:
parent
e67a57fb17
commit
3da144a3af
@ -77,7 +77,7 @@ class TestAccountController(unittest.TestCase):
|
||||
'HTTP_X_TIMESTAMP': '0'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue('X-Account-Status' not in resp.headers)
|
||||
self.assertNotIn('X-Account-Status', resp.headers)
|
||||
|
||||
def test_DELETE_empty(self):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
|
||||
@ -243,7 +243,7 @@ class TestAccountController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue('X-Account-Status' not in resp.headers)
|
||||
self.assertNotIn('X-Account-Status', resp.headers)
|
||||
|
||||
# Test the case in which account was deleted but not yet reaped
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
|
||||
@ -356,7 +356,7 @@ class TestAccountController(unittest.TestCase):
|
||||
'X-Timestamp': normalize_timestamp(0)})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue('X-Account-Status' not in resp.headers)
|
||||
self.assertNotIn('X-Account-Status', resp.headers)
|
||||
|
||||
def test_PUT(self):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
|
||||
@ -501,7 +501,7 @@ class TestAccountController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
self.assertTrue('x-account-meta-test' not in resp.headers)
|
||||
self.assertNotIn('x-account-meta-test', resp.headers)
|
||||
|
||||
def test_PUT_GET_sys_metadata(self):
|
||||
prefix = get_sys_meta_prefix('account')
|
||||
@ -562,7 +562,7 @@ class TestAccountController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
self.assertTrue(hdr not in resp.headers)
|
||||
self.assertNotIn(hdr, resp.headers)
|
||||
|
||||
def test_PUT_invalid_partition(self):
|
||||
req = Request.blank('/sda1/./a', environ={'REQUEST_METHOD': 'PUT',
|
||||
@ -626,7 +626,7 @@ class TestAccountController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
self.assertTrue('x-account-meta-test' not in resp.headers)
|
||||
self.assertNotIn('x-account-meta-test', resp.headers)
|
||||
|
||||
def test_POST_HEAD_sys_metadata(self):
|
||||
prefix = get_sys_meta_prefix('account')
|
||||
@ -679,7 +679,7 @@ class TestAccountController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'HEAD'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
self.assertTrue(hdr not in resp.headers)
|
||||
self.assertNotIn(hdr, resp.headers)
|
||||
|
||||
def test_POST_invalid_partition(self):
|
||||
req = Request.blank('/sda1/./a', environ={'REQUEST_METHOD': 'POST',
|
||||
@ -721,7 +721,7 @@ class TestAccountController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue('X-Account-Status' not in resp.headers)
|
||||
self.assertNotIn('X-Account-Status', resp.headers)
|
||||
|
||||
# Test the case in which account was deleted but not yet reaped
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'PUT',
|
||||
@ -1963,7 +1963,7 @@ class TestAccountController(unittest.TestCase):
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int // 100, 2)
|
||||
for key in resp.headers:
|
||||
self.assertTrue('storage-policy' not in key.lower())
|
||||
self.assertNotIn('storage-policy', key.lower())
|
||||
|
||||
def test_empty_except_for_used_policies(self):
|
||||
ts = itertools.count()
|
||||
@ -1979,7 +1979,7 @@ class TestAccountController(unittest.TestCase):
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int // 100, 2)
|
||||
for key in resp.headers:
|
||||
self.assertTrue('storage-policy' not in key.lower())
|
||||
self.assertNotIn('storage-policy', key.lower())
|
||||
|
||||
# add a container
|
||||
policy = random.choice(POLICIES)
|
||||
|
@ -242,7 +242,7 @@ class TestFormPost(unittest.TestCase):
|
||||
'/v1/a/c/o',
|
||||
environ={'REQUEST_METHOD': method}).get_response(self.formpost)
|
||||
self.assertEqual(resp.status_int, 401)
|
||||
self.assertTrue('FormPost' not in resp.body)
|
||||
self.assertNotIn('FormPost', resp.body)
|
||||
|
||||
def test_auth_scheme(self):
|
||||
# FormPost rejects
|
||||
|
@ -92,8 +92,8 @@ class TestGatekeeper(unittest.TestCase):
|
||||
|
||||
def _assertHeadersAbsent(self, unexpected, actual):
|
||||
for key in unexpected:
|
||||
self.assertTrue(key.lower() not in actual,
|
||||
'%s is in %s' % (key, actual))
|
||||
self.assertNotIn(key.lower(), actual,
|
||||
'%s is in %s' % (key, actual))
|
||||
|
||||
def get_app(self, app, global_conf, **local_conf):
|
||||
factory = gatekeeper.filter_factory(global_conf, **local_conf)
|
||||
|
@ -455,8 +455,8 @@ class TestProxyLogging(unittest.TestCase):
|
||||
headers = unquote(log_parts[14]).split('\n')
|
||||
self.assertTrue('First: 1' in headers)
|
||||
self.assertTrue('Second: 2' in headers)
|
||||
self.assertTrue('Third: 3' not in headers)
|
||||
self.assertTrue('Host: localhost:80' not in headers)
|
||||
self.assertNotIn('Third: 3', headers)
|
||||
self.assertNotIn('Host: localhost:80', headers)
|
||||
|
||||
def test_upload_size(self):
|
||||
# Using default policy
|
||||
|
@ -468,7 +468,7 @@ class TestSloPutManifest(SloTestCase):
|
||||
'/v1/AUTH_test/c/man?multipart-manifest=put',
|
||||
environ={'REQUEST_METHOD': 'PUT'}, headers={'Accept': 'test'},
|
||||
body=test_json_data)
|
||||
self.assertTrue('X-Static-Large-Object' not in req.headers)
|
||||
self.assertNotIn('X-Static-Large-Object', req.headers)
|
||||
self.slo(req.environ, fake_start_response)
|
||||
self.assertTrue('X-Static-Large-Object' in req.headers)
|
||||
self.assertTrue(req.environ['PATH_INFO'], '/cont/object\xe2\x99\xa1')
|
||||
@ -1728,7 +1728,7 @@ class TestSloGetManifest(SloTestCase):
|
||||
|
||||
self.assertEqual(status, '206 Partial Content')
|
||||
self.assertEqual(headers['Content-Length'], '15')
|
||||
self.assertTrue('Etag' not in headers)
|
||||
self.assertNotIn('Etag', headers)
|
||||
self.assertEqual(body, 'aabbbbbbbbbbccc')
|
||||
|
||||
self.assertEqual(
|
||||
@ -1973,7 +1973,7 @@ class TestSloGetManifest(SloTestCase):
|
||||
|
||||
self.assertEqual(status, '206 Partial Content')
|
||||
self.assertEqual(headers['Content-Length'], '25')
|
||||
self.assertTrue('Etag' not in headers)
|
||||
self.assertNotIn('Etag', headers)
|
||||
self.assertEqual(body, 'bbbbbbbbbbccccccccccccccc')
|
||||
|
||||
self.assertEqual(
|
||||
|
@ -556,8 +556,8 @@ class TestStaticWeb(unittest.TestCase):
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertTrue('Listing of /v1/a/c3/subdir/' in resp.body)
|
||||
self.assertTrue('</style>' in resp.body)
|
||||
self.assertTrue('<link' not in resp.body)
|
||||
self.assertTrue('listing.css' not in resp.body)
|
||||
self.assertNotIn('<link', resp.body)
|
||||
self.assertNotIn('listing.css', resp.body)
|
||||
|
||||
def test_container3subdirx(self):
|
||||
resp = Request.blank(
|
||||
@ -578,7 +578,7 @@ class TestStaticWeb(unittest.TestCase):
|
||||
resp = Request.blank(
|
||||
'/v1/a/c3/unknown').get_response(self.test_staticweb)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue("Chrome's 404 fancy-page sucks." not in resp.body)
|
||||
self.assertNotIn("Chrome's 404 fancy-page sucks.", resp.body)
|
||||
|
||||
def test_container3bindexhtml(self):
|
||||
resp = Request.blank('/v1/a/c3b/').get_response(self.test_staticweb)
|
||||
@ -616,7 +616,7 @@ class TestStaticWeb(unittest.TestCase):
|
||||
'/v1/a/c4/subdir/').get_response(self.test_staticweb)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
self.assertTrue('Listing of /v1/a/c4/subdir/' in resp.body)
|
||||
self.assertTrue('</style>' not in resp.body)
|
||||
self.assertNotIn('</style>', resp.body)
|
||||
self.assertTrue('<link' in resp.body)
|
||||
self.assertTrue('href="../listing.css"' in resp.body)
|
||||
self.assertEqual(resp.headers['content-type'],
|
||||
@ -640,7 +640,7 @@ class TestStaticWeb(unittest.TestCase):
|
||||
resp = Request.blank(
|
||||
'/v1/a/c5/unknown').get_response(self.test_staticweb)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue("Chrome's 404 fancy-page sucks." not in resp.body)
|
||||
self.assertNotIn("Chrome's 404 fancy-page sucks.", resp.body)
|
||||
|
||||
def test_container6subdir(self):
|
||||
resp = Request.blank(
|
||||
@ -796,7 +796,7 @@ class TestStaticWeb(unittest.TestCase):
|
||||
resp = Request.blank('/v1/a/c7/').get_response(
|
||||
self.test_staticweb)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue('listing.css' not in resp.body)
|
||||
self.assertNotIn('listing.css', resp.body)
|
||||
self.assertTrue('<style' in resp.body)
|
||||
|
||||
def test_subrequest_once_if_possible(self):
|
||||
|
@ -204,14 +204,14 @@ class TestAuth(unittest.TestCase):
|
||||
environ={'swift.authorize_override': True})
|
||||
resp = req.get_response(self.test_auth)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue('swift.authorize' not in req.environ)
|
||||
self.assertNotIn('swift.authorize', req.environ)
|
||||
|
||||
def test_override_default_allowed(self):
|
||||
req = self._make_request('/v1/AUTH_account',
|
||||
environ={'swift.authorize_override': True})
|
||||
resp = req.get_response(self.test_auth)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue('swift.authorize' not in req.environ)
|
||||
self.assertNotIn('swift.authorize', req.environ)
|
||||
|
||||
def test_auth_deny_non_reseller_prefix(self):
|
||||
req = self._make_request('/v1/BLAH_account',
|
||||
|
@ -116,7 +116,7 @@ class TestTempURL(unittest.TestCase):
|
||||
def test_passthrough(self):
|
||||
resp = self._make_request('/v1/a/c/o').get_response(self.tempurl)
|
||||
self.assertEqual(resp.status_int, 401)
|
||||
self.assertTrue('Temp URL invalid' not in resp.body)
|
||||
self.assertNotIn('Temp URL invalid', resp.body)
|
||||
|
||||
def test_allow_options(self):
|
||||
self.app.status_headers_body_iter = iter([('200 Ok', {}, '')])
|
||||
@ -821,7 +821,7 @@ class TestTempURL(unittest.TestCase):
|
||||
sig, expires)})
|
||||
resp = req.get_response(self.tempurl)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue('x-remove-this' not in self.app.request.headers)
|
||||
self.assertNotIn('x-remove-this', self.app.request.headers)
|
||||
|
||||
def test_removed_incoming_headers_match(self):
|
||||
self.tempurl = tempurl.filter_factory({
|
||||
@ -841,7 +841,7 @@ class TestTempURL(unittest.TestCase):
|
||||
sig, expires)})
|
||||
resp = req.get_response(self.tempurl)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue('x-remove-this-one' not in self.app.request.headers)
|
||||
self.assertNotIn('x-remove-this-one', self.app.request.headers)
|
||||
self.assertEqual(
|
||||
self.app.request.headers['x-remove-this-except-this'], 'value2')
|
||||
|
||||
@ -898,7 +898,7 @@ class TestTempURL(unittest.TestCase):
|
||||
sig, expires)})
|
||||
resp = req.get_response(self.tempurl)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertTrue('x-test-header-one-a' not in resp.headers)
|
||||
self.assertNotIn('x-test-header-one-a', resp.headers)
|
||||
self.assertEqual(resp.headers['x-test-header-two-a'], 'value2')
|
||||
|
||||
def test_removed_outgoing_headers_match(self):
|
||||
@ -918,7 +918,7 @@ class TestTempURL(unittest.TestCase):
|
||||
resp = req.get_response(self.tempurl)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertEqual(resp.headers['x-test-header-one-a'], 'value1')
|
||||
self.assertTrue('x-test-header-two-a' not in resp.headers)
|
||||
self.assertNotIn('x-test-header-two-a', resp.headers)
|
||||
self.assertEqual(resp.headers['x-test-header-two-b'], 'value3')
|
||||
|
||||
def test_allow_trumps_outgoing_header_conflict(self):
|
||||
@ -1074,9 +1074,9 @@ class TestTempURL(unittest.TestCase):
|
||||
resp = self._make_request('/v1/a/c/o', environ=environ).get_response(
|
||||
self.tempurl)
|
||||
self.assertEqual(resp.status_int, 401)
|
||||
self.assertTrue('Temp URL invalid' not in resp.body)
|
||||
self.assertNotIn('Temp URL invalid', resp.body)
|
||||
self.assertTrue('Www-Authenticate' in resp.headers)
|
||||
self.assertTrue('swift.auth_scheme' not in environ)
|
||||
self.assertNotIn('swift.auth_scheme', environ)
|
||||
|
||||
# Rejected by TempURL
|
||||
environ = {'REQUEST_METHOD': 'PUT',
|
||||
@ -1106,7 +1106,7 @@ class TestTempURL(unittest.TestCase):
|
||||
None, {'incoming_remove_headers': irh,
|
||||
'incoming_allow_headers': iah}
|
||||
)._clean_incoming_headers(env)
|
||||
self.assertTrue('HTTP_TEST_HEADER' not in env)
|
||||
self.assertNotIn('HTTP_TEST_HEADER', env)
|
||||
|
||||
irh = ['test-header-*']
|
||||
iah = []
|
||||
@ -1116,8 +1116,8 @@ class TestTempURL(unittest.TestCase):
|
||||
None, {'incoming_remove_headers': irh,
|
||||
'incoming_allow_headers': iah}
|
||||
)._clean_incoming_headers(env)
|
||||
self.assertTrue('HTTP_TEST_HEADER_ONE' not in env)
|
||||
self.assertTrue('HTTP_TEST_HEADER_TWO' not in env)
|
||||
self.assertNotIn('HTTP_TEST_HEADER_ONE', env)
|
||||
self.assertNotIn('HTTP_TEST_HEADER_TWO', env)
|
||||
|
||||
irh = ['test-header-*']
|
||||
iah = ['test-header-two']
|
||||
@ -1127,7 +1127,7 @@ class TestTempURL(unittest.TestCase):
|
||||
None, {'incoming_remove_headers': irh,
|
||||
'incoming_allow_headers': iah}
|
||||
)._clean_incoming_headers(env)
|
||||
self.assertTrue('HTTP_TEST_HEADER_ONE' not in env)
|
||||
self.assertNotIn('HTTP_TEST_HEADER_ONE', env)
|
||||
self.assertTrue('HTTP_TEST_HEADER_TWO' in env)
|
||||
|
||||
irh = ['test-header-*', 'test-other-header']
|
||||
@ -1141,10 +1141,10 @@ class TestTempURL(unittest.TestCase):
|
||||
None, {'incoming_remove_headers': irh,
|
||||
'incoming_allow_headers': iah}
|
||||
)._clean_incoming_headers(env)
|
||||
self.assertTrue('HTTP_TEST_HEADER_ONE' not in env)
|
||||
self.assertNotIn('HTTP_TEST_HEADER_ONE', env)
|
||||
self.assertTrue('HTTP_TEST_HEADER_TWO' in env)
|
||||
self.assertTrue('HTTP_TEST_OTHER_HEADER' not in env)
|
||||
self.assertTrue('HTTP_TEST_HEADER_YES' not in env)
|
||||
self.assertNotIn('HTTP_TEST_OTHER_HEADER', env)
|
||||
self.assertNotIn('HTTP_TEST_HEADER_YES', env)
|
||||
self.assertTrue('HTTP_TEST_HEADER_YES_THIS' in env)
|
||||
|
||||
def test_clean_outgoing_headers(self):
|
||||
@ -1164,7 +1164,7 @@ class TestTempURL(unittest.TestCase):
|
||||
None,
|
||||
{'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah}
|
||||
)._clean_outgoing_headers(hdrs.items()))
|
||||
self.assertTrue('test-header' not in hdrs)
|
||||
self.assertNotIn('test-header', hdrs)
|
||||
|
||||
orh = ['test-header-*']
|
||||
oah = []
|
||||
@ -1174,8 +1174,8 @@ class TestTempURL(unittest.TestCase):
|
||||
None,
|
||||
{'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah}
|
||||
)._clean_outgoing_headers(hdrs.items()))
|
||||
self.assertTrue('test-header-one' not in hdrs)
|
||||
self.assertTrue('test-header-two' not in hdrs)
|
||||
self.assertNotIn('test-header-one', hdrs)
|
||||
self.assertNotIn('test-header-two', hdrs)
|
||||
|
||||
orh = ['test-header-*']
|
||||
oah = ['test-header-two']
|
||||
@ -1185,7 +1185,7 @@ class TestTempURL(unittest.TestCase):
|
||||
None,
|
||||
{'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah}
|
||||
)._clean_outgoing_headers(hdrs.items()))
|
||||
self.assertTrue('test-header-one' not in hdrs)
|
||||
self.assertNotIn('test-header-one', hdrs)
|
||||
self.assertTrue('test-header-two' in hdrs)
|
||||
|
||||
orh = ['test-header-*', 'test-other-header']
|
||||
@ -1199,10 +1199,10 @@ class TestTempURL(unittest.TestCase):
|
||||
None,
|
||||
{'outgoing_remove_headers': orh, 'outgoing_allow_headers': oah}
|
||||
)._clean_outgoing_headers(hdrs.items()))
|
||||
self.assertTrue('test-header-one' not in hdrs)
|
||||
self.assertNotIn('test-header-one', hdrs)
|
||||
self.assertTrue('test-header-two' in hdrs)
|
||||
self.assertTrue('test-other-header' not in hdrs)
|
||||
self.assertTrue('test-header-yes' not in hdrs)
|
||||
self.assertNotIn('test-other-header', hdrs)
|
||||
self.assertNotIn('test-header-yes', hdrs)
|
||||
self.assertTrue('test-header-yes-this' in hdrs)
|
||||
|
||||
def test_unicode_metadata_value(self):
|
||||
|
@ -1131,7 +1131,7 @@ class TestDatabaseBroker(unittest.TestCase):
|
||||
self.assertTrue('First' in broker.metadata)
|
||||
self.assertEqual(broker.metadata['First'],
|
||||
[first_value, first_timestamp])
|
||||
self.assertTrue('Second' not in broker.metadata)
|
||||
self.assertNotIn('Second', broker.metadata)
|
||||
|
||||
@patch.object(DatabaseBroker, 'validate_metadata')
|
||||
def test_validate_metadata_is_called_from_update_metadata(self, mock):
|
||||
|
@ -528,8 +528,8 @@ class TestDirectClient(unittest.TestCase):
|
||||
|
||||
self.assertEqual(conn.req_headers['user-agent'], self.user_agent)
|
||||
self.assertEqual('bar', conn.req_headers.get('x-foo'))
|
||||
self.assertTrue('x-timestamp' not in conn.req_headers,
|
||||
'x-timestamp was in HEAD request headers')
|
||||
self.assertNotIn('x-timestamp', conn.req_headers,
|
||||
'x-timestamp was in HEAD request headers')
|
||||
self.assertEqual(headers, resp)
|
||||
|
||||
def test_direct_head_object_error(self):
|
||||
|
@ -741,8 +741,8 @@ class TestServer(unittest.TestCase):
|
||||
manager.os = MockOs([2])
|
||||
# test pid not running
|
||||
pids = server.signal_pids(signal.SIG_DFL)
|
||||
self.assertTrue(1 not in pids)
|
||||
self.assertTrue(1 not in manager.os.pid_sigs)
|
||||
self.assertNotIn(1, pids)
|
||||
self.assertNotIn(1, manager.os.pid_sigs)
|
||||
# test remove stale pid file
|
||||
self.assertFalse(os.path.exists(
|
||||
self.join_run_dir('proxy-server.pid')))
|
||||
@ -818,8 +818,8 @@ class TestServer(unittest.TestCase):
|
||||
running_pids = server.get_running_pids()
|
||||
self.assertEqual(len(running_pids), 1)
|
||||
self.assertTrue(1 in running_pids)
|
||||
self.assertTrue(2 not in running_pids)
|
||||
self.assertTrue(3 not in running_pids)
|
||||
self.assertNotIn(2, running_pids)
|
||||
self.assertNotIn(3, running_pids)
|
||||
# test persistent running pid files
|
||||
self.assertTrue(os.path.exists(
|
||||
os.path.join(manager.RUN_DIR, 'test-server1.pid')))
|
||||
@ -857,7 +857,7 @@ class TestServer(unittest.TestCase):
|
||||
self.assertTrue(1 in running_pids)
|
||||
# no other pids returned
|
||||
for n in (2, 3, 4):
|
||||
self.assertTrue(n not in running_pids)
|
||||
self.assertNotIn(n, running_pids)
|
||||
# assert stale pids for other servers ignored
|
||||
manager.os = MockOs([1]) # only thing-doer is running
|
||||
running_pids = server.get_running_pids()
|
||||
@ -922,7 +922,7 @@ class TestServer(unittest.TestCase):
|
||||
self.assertEqual(manager.os.pid_sigs[pid],
|
||||
[signal.SIGTERM])
|
||||
# and the other pid is of course not signaled
|
||||
self.assertTrue(1 not in manager.os.pid_sigs)
|
||||
self.assertNotIn(1, manager.os.pid_sigs)
|
||||
|
||||
def test_status(self):
|
||||
conf_files = (
|
||||
@ -1245,7 +1245,7 @@ class TestServer(unittest.TestCase):
|
||||
self.assertTrue('mock process started' in output)
|
||||
self.assertTrue('setup complete' in output)
|
||||
# make sure we don't get prints after stdout was closed
|
||||
self.assertTrue('mock process finished' not in output)
|
||||
self.assertNotIn('mock process finished', output)
|
||||
# test process which fails to start
|
||||
with MockProcess(fail_to_start=True) as proc:
|
||||
server.procs = [proc]
|
||||
@ -1386,7 +1386,7 @@ class TestServer(unittest.TestCase):
|
||||
self.assertEqual(mock_spawn.kwargs, [expected])
|
||||
output = pop_stream(f)
|
||||
self.assertTrue('Starting' in output)
|
||||
self.assertTrue('once' not in output)
|
||||
self.assertNotIn('once', output)
|
||||
# test multi-server kwarg once
|
||||
server = manager.Server('object-replicator')
|
||||
with temptree([], []) as proc_dir:
|
||||
|
@ -270,7 +270,7 @@ class TestMatch(unittest.TestCase):
|
||||
self.assertEqual(match.tags, set(('a', 'b')))
|
||||
self.assertTrue('a' in match)
|
||||
self.assertTrue('b' in match)
|
||||
self.assertTrue('c' not in match)
|
||||
self.assertNotIn('c', match)
|
||||
|
||||
def test_match_star(self):
|
||||
match = swift.common.swob.Match('"a", "*"')
|
||||
@ -283,7 +283,7 @@ class TestMatch(unittest.TestCase):
|
||||
self.assertEqual(match.tags, set(('a', 'b')))
|
||||
self.assertTrue('a' in match)
|
||||
self.assertTrue('b' in match)
|
||||
self.assertTrue('c' not in match)
|
||||
self.assertNotIn('c', match)
|
||||
|
||||
|
||||
class TestTransferEncoding(unittest.TestCase):
|
||||
@ -724,7 +724,7 @@ class TestRequest(unittest.TestCase):
|
||||
|
||||
req = swift.common.swob.Request.blank('/')
|
||||
resp = req.get_response(test_app)
|
||||
self.assertTrue('Www-Authenticate' not in resp.headers)
|
||||
self.assertNotIn('Www-Authenticate', resp.headers)
|
||||
|
||||
def test_properties(self):
|
||||
req = swift.common.swob.Request.blank('/hi/there', body='hi')
|
||||
@ -744,7 +744,7 @@ class TestRequest(unittest.TestCase):
|
||||
|
||||
self.assertTrue('Range' in req.headers)
|
||||
req.range = None
|
||||
self.assertTrue('Range' not in req.headers)
|
||||
self.assertNotIn('Range', req.headers)
|
||||
|
||||
def test_datetime_properties(self):
|
||||
req = swift.common.swob.Request.blank('/hi/there', body='hi')
|
||||
@ -761,7 +761,7 @@ class TestRequest(unittest.TestCase):
|
||||
|
||||
self.assertTrue('If-Unmodified-Since' in req.headers)
|
||||
req.if_unmodified_since = None
|
||||
self.assertTrue('If-Unmodified-Since' not in req.headers)
|
||||
self.assertNotIn('If-Unmodified-Since', req.headers)
|
||||
|
||||
too_big_date_list = list(datetime.datetime.max.timetuple())
|
||||
too_big_date_list[0] += 1 # bump up the year
|
||||
@ -1032,12 +1032,12 @@ class TestResponse(unittest.TestCase):
|
||||
self.assertEqual(resp.location, 'something')
|
||||
self.assertTrue('Location' in resp.headers)
|
||||
resp.location = None
|
||||
self.assertTrue('Location' not in resp.headers)
|
||||
self.assertNotIn('Location', resp.headers)
|
||||
|
||||
resp.content_type = 'text/plain'
|
||||
self.assertTrue('Content-Type' in resp.headers)
|
||||
resp.content_type = None
|
||||
self.assertTrue('Content-Type' not in resp.headers)
|
||||
self.assertNotIn('Content-Type', resp.headers)
|
||||
|
||||
def test_empty_body(self):
|
||||
resp = self._get_response()
|
||||
@ -1359,7 +1359,7 @@ class TestResponse(unittest.TestCase):
|
||||
|
||||
self.assertTrue('etag' in resp.headers)
|
||||
resp.etag = None
|
||||
self.assertTrue('etag' not in resp.headers)
|
||||
self.assertNotIn('etag', resp.headers)
|
||||
|
||||
def test_host_url_default(self):
|
||||
resp = self._get_response()
|
||||
|
@ -1314,7 +1314,7 @@ class TestUtils(unittest.TestCase):
|
||||
self.assertEqual(conf, conf_file)
|
||||
# assert defaults
|
||||
self.assertEqual(options['verbose'], False)
|
||||
self.assertTrue('once' not in options)
|
||||
self.assertNotIn('once', options)
|
||||
# assert verbose as option
|
||||
conf, options = utils.parse_options(test_args=[conf_file, '-v'])
|
||||
self.assertEqual(options['verbose'], True)
|
||||
@ -1549,7 +1549,7 @@ class TestUtils(unittest.TestCase):
|
||||
for en in (errno.EIO, errno.ENOSPC):
|
||||
log_exception(OSError(en, 'my %s error message' % en))
|
||||
log_msg = strip_value(sio)
|
||||
self.assertTrue('Traceback' not in log_msg)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertTrue('my %s error message' % en in log_msg)
|
||||
# unfiltered
|
||||
log_exception(OSError())
|
||||
@ -1559,19 +1559,19 @@ class TestUtils(unittest.TestCase):
|
||||
log_exception(socket.error(errno.ECONNREFUSED,
|
||||
'my error message'))
|
||||
log_msg = strip_value(sio)
|
||||
self.assertTrue('Traceback' not in log_msg)
|
||||
self.assertTrue('errno.ECONNREFUSED message test' not in log_msg)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertNotIn('errno.ECONNREFUSED message test', log_msg)
|
||||
self.assertTrue('Connection refused' in log_msg)
|
||||
log_exception(socket.error(errno.EHOSTUNREACH,
|
||||
'my error message'))
|
||||
log_msg = strip_value(sio)
|
||||
self.assertTrue('Traceback' not in log_msg)
|
||||
self.assertTrue('my error message' not in log_msg)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertNotIn('my error message', log_msg)
|
||||
self.assertTrue('Host unreachable' in log_msg)
|
||||
log_exception(socket.error(errno.ETIMEDOUT, 'my error message'))
|
||||
log_msg = strip_value(sio)
|
||||
self.assertTrue('Traceback' not in log_msg)
|
||||
self.assertTrue('my error message' not in log_msg)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertNotIn('my error message', log_msg)
|
||||
self.assertTrue('Connection timeout' in log_msg)
|
||||
# unfiltered
|
||||
log_exception(socket.error(0, 'my error message'))
|
||||
@ -1583,16 +1583,16 @@ class TestUtils(unittest.TestCase):
|
||||
connection_timeout = ConnectionTimeout(42, 'my error message')
|
||||
log_exception(connection_timeout)
|
||||
log_msg = strip_value(sio)
|
||||
self.assertTrue('Traceback' not in log_msg)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertTrue('ConnectionTimeout' in log_msg)
|
||||
self.assertTrue('(42s)' in log_msg)
|
||||
self.assertTrue('my error message' not in log_msg)
|
||||
self.assertNotIn('my error message', log_msg)
|
||||
connection_timeout.cancel()
|
||||
|
||||
message_timeout = MessageTimeout(42, 'my error message')
|
||||
log_exception(message_timeout)
|
||||
log_msg = strip_value(sio)
|
||||
self.assertTrue('Traceback' not in log_msg)
|
||||
self.assertNotIn('Traceback', log_msg)
|
||||
self.assertTrue('MessageTimeout' in log_msg)
|
||||
self.assertTrue('(42s)' in log_msg)
|
||||
self.assertTrue('my error message' in log_msg)
|
||||
@ -1683,7 +1683,7 @@ class TestUtils(unittest.TestCase):
|
||||
logger.error('my error message')
|
||||
log_msg = strip_value(sio)
|
||||
self.assertTrue('my error message' in log_msg)
|
||||
self.assertTrue('txn' not in log_msg)
|
||||
self.assertNotIn('txn', log_msg)
|
||||
logger.txn_id = '12345'
|
||||
logger.error('test')
|
||||
log_msg = strip_value(sio)
|
||||
@ -1709,7 +1709,7 @@ class TestUtils(unittest.TestCase):
|
||||
logger.error('my error message')
|
||||
log_msg = strip_value(sio)
|
||||
self.assertTrue('my error message' in log_msg)
|
||||
self.assertTrue('client_ip' not in log_msg)
|
||||
self.assertNotIn('client_ip', log_msg)
|
||||
logger.client_ip = '1.2.3.4'
|
||||
logger.error('test')
|
||||
log_msg = strip_value(sio)
|
||||
@ -1719,8 +1719,8 @@ class TestUtils(unittest.TestCase):
|
||||
self.assertEqual(logger.client_ip, '1.2.3.4')
|
||||
logger.info('test')
|
||||
log_msg = strip_value(sio)
|
||||
self.assertTrue('client_ip' not in log_msg)
|
||||
self.assertTrue('1.2.3.4' not in log_msg)
|
||||
self.assertNotIn('client_ip', log_msg)
|
||||
self.assertNotIn('1.2.3.4', log_msg)
|
||||
# test client_ip (and txn) already in message
|
||||
self.assertEqual(logger.client_ip, '1.2.3.4')
|
||||
logger.warning('test 1.2.3.4 test 12345')
|
||||
@ -2128,7 +2128,7 @@ log_name = %(yarr)s'''
|
||||
for func in required_func_calls:
|
||||
self.assertTrue(utils.os.called_funcs[func])
|
||||
for func in bad_func_calls:
|
||||
self.assertTrue(func not in utils.os.called_funcs)
|
||||
self.assertNotIn(func, utils.os.called_funcs)
|
||||
|
||||
@reset_logger_state
|
||||
def test_capture_stdio(self):
|
||||
@ -4022,7 +4022,7 @@ class TestSwiftInfo(unittest.TestCase):
|
||||
|
||||
info = utils.get_swift_info()
|
||||
|
||||
self.assertTrue('admin' not in info)
|
||||
self.assertNotIn('admin', info)
|
||||
|
||||
self.assertTrue('swift' in info)
|
||||
self.assertTrue('foo' in info['swift'])
|
||||
@ -4041,19 +4041,19 @@ class TestSwiftInfo(unittest.TestCase):
|
||||
|
||||
info = utils.get_swift_info(disallowed_sections=['cap1', 'cap3'])
|
||||
|
||||
self.assertTrue('admin' not in info)
|
||||
self.assertNotIn('admin', info)
|
||||
|
||||
self.assertTrue('swift' in info)
|
||||
self.assertTrue('foo' in info['swift'])
|
||||
self.assertEqual(info['swift']['foo'], 'bar')
|
||||
|
||||
self.assertTrue('cap1' not in info)
|
||||
self.assertNotIn('cap1', info)
|
||||
|
||||
self.assertTrue('cap2' in info)
|
||||
self.assertTrue('cap2_foo' in info['cap2'])
|
||||
self.assertEqual(info['cap2']['cap2_foo'], 'cap2_bar')
|
||||
|
||||
self.assertTrue('cap3' not in info)
|
||||
self.assertNotIn('cap3', info)
|
||||
|
||||
def test_register_swift_admin_info(self):
|
||||
utils.register_swift_info(admin=True, admin_foo='admin_bar')
|
||||
@ -4077,8 +4077,8 @@ class TestSwiftInfo(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
utils._swift_admin_info['cap1']['ac1_lorem'], 'ac1_ipsum')
|
||||
|
||||
self.assertTrue('swift' not in utils._swift_info)
|
||||
self.assertTrue('cap1' not in utils._swift_info)
|
||||
self.assertNotIn('swift', utils._swift_info)
|
||||
self.assertNotIn('cap1', utils._swift_info)
|
||||
|
||||
def test_get_swift_admin_info(self):
|
||||
utils._swift_info = {'swift': {'foo': 'bar'},
|
||||
@ -4116,20 +4116,20 @@ class TestSwiftInfo(unittest.TestCase):
|
||||
self.assertEqual(info['admin']['admin_cap1']['ac1_foo'], 'ac1_bar')
|
||||
self.assertTrue('disallowed_sections' in info['admin'])
|
||||
self.assertTrue('cap1' in info['admin']['disallowed_sections'])
|
||||
self.assertTrue('cap2' not in info['admin']['disallowed_sections'])
|
||||
self.assertNotIn('cap2', info['admin']['disallowed_sections'])
|
||||
self.assertTrue('cap3' in info['admin']['disallowed_sections'])
|
||||
|
||||
self.assertTrue('swift' in info)
|
||||
self.assertTrue('foo' in info['swift'])
|
||||
self.assertEqual(info['swift']['foo'], 'bar')
|
||||
|
||||
self.assertTrue('cap1' not in info)
|
||||
self.assertNotIn('cap1', info)
|
||||
|
||||
self.assertTrue('cap2' in info)
|
||||
self.assertTrue('cap2_foo' in info['cap2'])
|
||||
self.assertEqual(info['cap2']['cap2_foo'], 'cap2_bar')
|
||||
|
||||
self.assertTrue('cap3' not in info)
|
||||
self.assertNotIn('cap3', info)
|
||||
|
||||
def test_get_swift_admin_info_with_disallowed_sub_sections(self):
|
||||
utils._swift_info = {'swift': {'foo': 'bar'},
|
||||
@ -4144,10 +4144,10 @@ class TestSwiftInfo(unittest.TestCase):
|
||||
info = utils.get_swift_info(
|
||||
admin=True, disallowed_sections=['cap1.cap1_foo', 'cap3',
|
||||
'cap4.a.b.c'])
|
||||
self.assertTrue('cap3' not in info)
|
||||
self.assertNotIn('cap3', info)
|
||||
self.assertEqual(info['cap1']['cap1_moo'], 'cap1_baa')
|
||||
self.assertTrue('cap1_foo' not in info['cap1'])
|
||||
self.assertTrue('c' not in info['cap4']['a']['b'])
|
||||
self.assertNotIn('cap1_foo', info['cap1'])
|
||||
self.assertNotIn('c', info['cap4']['a']['b'])
|
||||
self.assertEqual(info['cap4']['a']['b.c'], 'b.c')
|
||||
|
||||
def test_get_swift_info_with_unmatched_disallowed_sections(self):
|
||||
|
@ -137,8 +137,8 @@ class TestContainerController(unittest.TestCase):
|
||||
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
|
||||
response = req.get_response(self.controller)
|
||||
self.assertTrue(response.status.startswith('204'))
|
||||
self.assertTrue('x-container-read' not in response.headers)
|
||||
self.assertTrue('x-container-write' not in response.headers)
|
||||
self.assertNotIn('x-container-read', response.headers)
|
||||
self.assertNotIn('x-container-write', response.headers)
|
||||
# Ensure POSTing acls works
|
||||
req = Request.blank(
|
||||
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'POST'},
|
||||
@ -164,8 +164,8 @@ class TestContainerController(unittest.TestCase):
|
||||
'/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
|
||||
response = req.get_response(self.controller)
|
||||
self.assertTrue(response.status.startswith('204'))
|
||||
self.assertTrue('x-container-read' not in response.headers)
|
||||
self.assertTrue('x-container-write' not in response.headers)
|
||||
self.assertNotIn('x-container-read', response.headers)
|
||||
self.assertNotIn('x-container-write', response.headers)
|
||||
# Ensure PUTing acls works
|
||||
req = Request.blank(
|
||||
'/sda1/p/a/c2', environ={'REQUEST_METHOD': 'PUT'},
|
||||
@ -737,7 +737,7 @@ class TestContainerController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
self.assertTrue('x-container-meta-test' not in resp.headers)
|
||||
self.assertNotIn('x-container-meta-test', resp.headers)
|
||||
|
||||
def test_PUT_GET_sys_metadata(self):
|
||||
prefix = get_sys_meta_prefix('container')
|
||||
@ -795,7 +795,7 @@ class TestContainerController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'GET'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
self.assertTrue(key.lower() not in resp.headers)
|
||||
self.assertNotIn(key.lower(), resp.headers)
|
||||
|
||||
def test_PUT_invalid_partition(self):
|
||||
req = Request.blank('/sda1/./a/c', environ={'REQUEST_METHOD': 'PUT',
|
||||
@ -878,7 +878,7 @@ class TestContainerController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
self.assertTrue('x-container-meta-test' not in resp.headers)
|
||||
self.assertNotIn('x-container-meta-test', resp.headers)
|
||||
self.assertEqual(resp.headers.get('x-put-timestamp'),
|
||||
'0000000004.00000')
|
||||
|
||||
@ -930,7 +930,7 @@ class TestContainerController(unittest.TestCase):
|
||||
req = Request.blank('/sda1/p/a/c', environ={'REQUEST_METHOD': 'HEAD'})
|
||||
resp = req.get_response(self.controller)
|
||||
self.assertEqual(resp.status_int, 204)
|
||||
self.assertTrue(key.lower() not in resp.headers)
|
||||
self.assertNotIn(key.lower(), resp.headers)
|
||||
|
||||
def test_POST_invalid_partition(self):
|
||||
req = Request.blank('/sda1/./a/c', environ={'REQUEST_METHOD': 'POST',
|
||||
|
@ -373,7 +373,7 @@ class TestObjectExpirer(TestCase):
|
||||
'Pass beginning; 1 possible containers; 2 possible objects',
|
||||
'Pass completed in 0s; 0 objects expired',
|
||||
])
|
||||
self.assertTrue('error' not in logs)
|
||||
self.assertNotIn('error', logs)
|
||||
|
||||
# Reverse test to be sure it still would blow up the way expected.
|
||||
fake_swift = InternalClient([{'name': str(int(time() - 86400))}])
|
||||
@ -414,7 +414,7 @@ class TestObjectExpirer(TestCase):
|
||||
x = expirer.ObjectExpirer(self.conf, logger=self.logger,
|
||||
swift=fake_swift)
|
||||
x.run_once()
|
||||
self.assertTrue('error' not in x.logger.all_log_lines())
|
||||
self.assertNotIn('error', x.logger.all_log_lines())
|
||||
self.assertEqual(x.logger.get_lines_for_level('info'), [
|
||||
'Pass beginning; 1 possible containers; 2 possible objects',
|
||||
'Pass completed in 0s; 0 objects expired',
|
||||
|
Loading…
Reference in New Issue
Block a user