Port test_servers to py3

Use base64 module from oslo.serialization to handle
base64 encoding and decoding.

Change-Id: Ib44eb337acabd68eb92ddc202c09768ae89a7eb1
Partially-Implements: blueprint goal-python35
This commit is contained in:
Kevin_Zheng
2016-12-10 17:33:27 +08:00
parent 4728c3e4fd
commit 29030c38af

View File

@@ -19,6 +19,7 @@ import zlib
import mock
from oslo_log import log as logging
from oslo_serialization import base64
from oslo_utils import timeutils
from nova.compute import api as compute_api
@@ -475,14 +476,14 @@ class ServersTest(ServersTestBase):
data = 'Hello, World!'
personality.append({
'path': '/helloworld.txt',
'contents': data.encode('base64'),
'contents': base64.encode_as_bytes(data),
})
# Inject a binary file
data = zlib.compress('Hello, World!')
personality.append({
'path': '/helloworld.zip',
'contents': data.encode('base64'),
'contents': base64.encode_as_bytes(data),
})
# Create server