Merge "Clean up dlo unit tests"
This commit is contained in:
commit
3be4d2f64b
@ -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,10 +584,7 @@ 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(body, b'aaaaa')
|
||||||
self.assertEqual(''.join(body), "aaaaa")
|
|
||||||
else:
|
|
||||||
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, '
|
||||||
'got 403 while retrieving /v1/AUTH_test/c/seg_02',
|
'got 403 while retrieving /v1/AUTH_test/c/seg_02',
|
||||||
@ -647,11 +642,8 @@ 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(body, b"aaaaabbWRONGbb")
|
||||||
self.assertEqual(''.join(body), "aaaaabbWRONGbb")
|
|
||||||
else:
|
|
||||||
self.assertEqual(body, b"aaaaabbWRONGbb")
|
|
||||||
|
|
||||||
def test_etag_comparison_ignores_quotes(self):
|
def test_etag_comparison_ignores_quotes(self):
|
||||||
# a little future-proofing here in case we ever fix this in swob
|
# a little future-proofing here in case we ever fix this in swob
|
||||||
@ -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