Merge "Use b64encode to replace of encodestring"
This commit is contained in:
commit
66b9b26bb1
@ -454,7 +454,7 @@ class Meter(base.Base):
|
||||
meter_id = '%s+%s' % (kwargs['resource_id'], kwargs['name'])
|
||||
# meter_id is of type Unicode but base64.encodestring() only accepts
|
||||
# strings. See bug #1333177
|
||||
meter_id = base64.encodestring(meter_id.encode('utf-8'))
|
||||
meter_id = base64.b64encode(meter_id.encode('utf-8'))
|
||||
kwargs['meter_id'] = meter_id
|
||||
super(Meter, self).__init__(**kwargs)
|
||||
|
||||
|
@ -785,7 +785,11 @@ class TestListMeters(v2.FunctionalTest,
|
||||
data = self.get_json('/meters')
|
||||
for i in data:
|
||||
meter_id = '%s+%s' % (i['resource_id'], i['name'])
|
||||
expected = base64.encodestring(meter_id.encode('utf-8'))
|
||||
expected = base64.b64encode(meter_id.encode('utf-8'))
|
||||
if six.PY3:
|
||||
expected = expected.decode('ascii')
|
||||
self.assertEqual(expected, i['meter_id'])
|
||||
self.assertFalse(i['meter_id'].endswith('\n'))
|
||||
self.assertEqual(
|
||||
[i['resource_id'].encode('utf-8'), i['name'].encode('utf-8')],
|
||||
base64.b64decode(i['meter_id']).split('+'))
|
||||
|
Loading…
Reference in New Issue
Block a user