fix broken UTs for python3 compatibility
This fix does following: 1. decode byte string into utf-8 before json.load 2. encode unicode to utf-8 before md5 checksum calculation Partially-Implements: blueprint designate-py3 Change-Id: I47e554fbcf3309fef724f50e3e67af601578e83c
This commit is contained in:
@@ -624,7 +624,8 @@ class SQLAlchemyStorage(sqlalchemy_base.SQLAlchemy, storage_base.Storage):
|
||||
Calculates the hash of the record, used to ensure record uniqueness.
|
||||
"""
|
||||
md5 = hashlib.md5()
|
||||
md5.update("%s:%s" % (record.recordset_id, record.data))
|
||||
md5.update(("%s:%s" % (record.recordset_id,
|
||||
record.data)).encode('utf-8'))
|
||||
|
||||
return md5.hexdigest()
|
||||
|
||||
|
||||
@@ -131,13 +131,14 @@ def resource_string(*args):
|
||||
def load_schema(version, name):
|
||||
schema_string = resource_string('schemas', version, '%s.json' % name)
|
||||
|
||||
return json.loads(schema_string)
|
||||
return json.loads(schema_string.decode('utf-8'))
|
||||
|
||||
|
||||
def load_template(template_name):
|
||||
template_string = resource_string('templates', template_name)
|
||||
|
||||
return Template(template_string, keep_trailing_newline=True)
|
||||
return Template(template_string.decode('utf-8'),
|
||||
keep_trailing_newline=True)
|
||||
|
||||
|
||||
def render_template(template, **template_context):
|
||||
|
||||
Reference in New Issue
Block a user