From c6b9195db840dc35eaef4136c6c6eb180ed8ead6 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Mon, 12 Dec 2016 11:58:01 -0800 Subject: [PATCH] More assertion cleanup Change-Id: Id88af19c5bfd0bcbbeabcf4eeb23beef4c50b1cb Related-Change: I416831c8ad92f8445bc8d9560040a5ebf5c90702 --- .../unit/common/middleware/test_gatekeeper.py | 6 +- .../common/middleware/test_proxy_logging.py | 4 +- test/unit/common/middleware/test_slo.py | 6 +- test/unit/common/middleware/test_staticweb.py | 24 ++--- test/unit/common/middleware/test_tempurl.py | 82 ++++++++--------- test/unit/common/test_db.py | 38 ++++---- test/unit/common/test_direct_client.py | 3 +- test/unit/common/test_manager.py | 28 +++--- test/unit/common/test_swob.py | 24 ++--- test/unit/common/test_utils.py | 92 +++++++++---------- 10 files changed, 153 insertions(+), 154 deletions(-) diff --git a/test/unit/common/middleware/test_gatekeeper.py b/test/unit/common/middleware/test_gatekeeper.py index 8c205afa31..888aeb6204 100644 --- a/test/unit/common/middleware/test_gatekeeper.py +++ b/test/unit/common/middleware/test_gatekeeper.py @@ -87,13 +87,11 @@ class TestGatekeeper(unittest.TestCase): def _assertHeadersEqual(self, expected, actual): for key in expected: - self.assertTrue(key.lower() in actual, - '%s missing from %s' % (key, actual)) + self.assertIn(key.lower(), actual) def _assertHeadersAbsent(self, unexpected, actual): for key in unexpected: - self.assertNotIn(key.lower(), actual, - '%s is in %s' % (key, actual)) + self.assertNotIn(key.lower(), actual) def get_app(self, app, global_conf, **local_conf): factory = gatekeeper.filter_factory(global_conf, **local_conf) diff --git a/test/unit/common/middleware/test_proxy_logging.py b/test/unit/common/middleware/test_proxy_logging.py index 909a96dac2..18e125570b 100644 --- a/test/unit/common/middleware/test_proxy_logging.py +++ b/test/unit/common/middleware/test_proxy_logging.py @@ -453,8 +453,8 @@ class TestProxyLogging(unittest.TestCase): [x for x in resp] log_parts = self._log_parts(app) headers = unquote(log_parts[14]).split('\n') - self.assertTrue('First: 1' in headers) - self.assertTrue('Second: 2' in headers) + self.assertIn('First: 1', headers) + self.assertIn('Second: 2', headers) self.assertNotIn('Third: 3', headers) self.assertNotIn('Host: localhost:80', headers) diff --git a/test/unit/common/middleware/test_slo.py b/test/unit/common/middleware/test_slo.py index 6f428b74de..befee0a1b1 100644 --- a/test/unit/common/middleware/test_slo.py +++ b/test/unit/common/middleware/test_slo.py @@ -470,8 +470,10 @@ class TestSloPutManifest(SloTestCase): body=test_json_data) 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') + self.assertIn('X-Static-Large-Object', req.headers) + self.assertEqual(req.environ['PATH_INFO'], '/v1/AUTH_test/c/man') + self.assertIn(('HEAD', '/v1/AUTH_test/cont/object\xe2\x99\xa1'), + self.app.calls) def test_handle_multipart_put_no_xml(self): req = Request.blank( diff --git a/test/unit/common/middleware/test_staticweb.py b/test/unit/common/middleware/test_staticweb.py index d6f89a4870..e25028cc1d 100644 --- a/test/unit/common/middleware/test_staticweb.py +++ b/test/unit/common/middleware/test_staticweb.py @@ -554,8 +554,8 @@ class TestStaticWeb(unittest.TestCase): resp = Request.blank( '/v1/a/c3/subdir/').get_response(self.test_staticweb) self.assertEqual(resp.status_int, 200) - self.assertTrue('Listing of /v1/a/c3/subdir/' in resp.body) - self.assertTrue('' in resp.body) + self.assertIn('Listing of /v1/a/c3/subdir/', resp.body) + self.assertIn('', resp.body) self.assertNotIn('', resp.body) - self.assertTrue('