Clean up dlo unit tests
We don't actually need so many py2/py3 branches, and once we clean those up, there's hardly any reason to import six. Change-Id: Ia3b4f02e7eb99ad1a76aa35c39dc198528fd39ad
This commit is contained in:
parent
893acffbc0
commit
b6ebabee78
@ -23,8 +23,6 @@ from textwrap import dedent
|
|||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from swift.common import swob
|
from swift.common import swob
|
||||||
from swift.common.header_key_dict import HeaderKeyDict
|
from swift.common.header_key_dict import HeaderKeyDict
|
||||||
from swift.common.middleware import dlo
|
from swift.common.middleware import dlo
|
||||||
@ -36,7 +34,7 @@ LIMIT = 'swift.common.constraints.CONTAINER_LISTING_LIMIT'
|
|||||||
|
|
||||||
|
|
||||||
def md5hex(s):
|
def md5hex(s):
|
||||||
if isinstance(s, six.text_type):
|
if not isinstance(s, bytes):
|
||||||
s = s.encode('utf-8')
|
s = s.encode('utf-8')
|
||||||
return hashlib.md5(s).hexdigest()
|
return hashlib.md5(s).hexdigest()
|
||||||
|
|
||||||
@ -586,9 +584,6 @@ class TestDloGetManifest(DloTestCase):
|
|||||||
|
|
||||||
self.assertEqual(status, "200 OK")
|
self.assertEqual(status, "200 OK")
|
||||||
# first segment made it out
|
# first segment made it out
|
||||||
if six.PY2:
|
|
||||||
self.assertEqual(''.join(body), "aaaaa")
|
|
||||||
else:
|
|
||||||
self.assertEqual(body, b'aaaaa')
|
self.assertEqual(body, b'aaaaa')
|
||||||
self.assertEqual(self.dlo.logger.get_lines_for_level('error'), [
|
self.assertEqual(self.dlo.logger.get_lines_for_level('error'), [
|
||||||
'While processing manifest /v1/AUTH_test/mancon/manifest, '
|
'While processing manifest /v1/AUTH_test/mancon/manifest, '
|
||||||
@ -647,10 +642,7 @@ class TestDloGetManifest(DloTestCase):
|
|||||||
headers = HeaderKeyDict(headers)
|
headers = HeaderKeyDict(headers)
|
||||||
|
|
||||||
self.assertEqual(status, "200 OK")
|
self.assertEqual(status, "200 OK")
|
||||||
if six.PY2:
|
|
||||||
# stop after error
|
# stop after error
|
||||||
self.assertEqual(''.join(body), "aaaaabbWRONGbb")
|
|
||||||
else:
|
|
||||||
self.assertEqual(body, b"aaaaabbWRONGbb")
|
self.assertEqual(body, b"aaaaabbWRONGbb")
|
||||||
|
|
||||||
def test_etag_comparison_ignores_quotes(self):
|
def test_etag_comparison_ignores_quotes(self):
|
||||||
@ -689,10 +681,8 @@ class TestDloGetManifest(DloTestCase):
|
|||||||
swob.HTTPOk, {'Content-Type': 'application/json'},
|
swob.HTTPOk, {'Content-Type': 'application/json'},
|
||||||
json.dumps(segs).encode('ascii'))
|
json.dumps(segs).encode('ascii'))
|
||||||
|
|
||||||
if six.PY2:
|
# NB: wsgi string
|
||||||
path = b'/v1/AUTH_test/c/\xC3\xa9'
|
path = '/v1/AUTH_test/c/\xC3\xa9'
|
||||||
else:
|
|
||||||
path = u'/v1/AUTH_test/c/\xc3\xa9'
|
|
||||||
self.app.register(
|
self.app.register(
|
||||||
'GET', path + '1',
|
'GET', path + '1',
|
||||||
swob.HTTPOk, {'Content-Length': '5', 'Etag': md5hex("AAAAA")},
|
swob.HTTPOk, {'Content-Length': '5', 'Etag': md5hex("AAAAA")},
|
||||||
|
Loading…
Reference in New Issue
Block a user