Port cloudfoundry/test_cfapi.py to Python 3

* Replace base64.b64encode() with base64.encode_as_text() to get
  Unicode on Python 3.
* tox.ini: add test_cfapi to py34

Blueprint: murano-python-3-support
Change-Id: Ib54758ebc7821a0cb32a756331f066191c025f3d
This commit is contained in:
Victor Stinner 2016-04-15 16:54:38 +02:00
parent 398b8cd987
commit 2461badd18
2 changed files with 6 additions and 5 deletions

View File

@ -12,10 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import base64
import json
import mock
from oslo_serialization import base64
from webob import response
from murano.api.v1.cloudfoundry import cfapi as api
@ -28,9 +27,10 @@ class TestController(base.MuranoTestCase):
self.controller = api.Controller()
self.request = mock.MagicMock()
self.request.headers = {'Authorization': 'Basic {encoded}'.format(
encoded=base64.b64encode('test:test')), 'X-Auth-Token': 'foo-bar',
'X-Project-Id': 'bar-baz'}
auth = 'Basic {}'.format(base64.encode_as_text(b'test:test'))
self.request.headers = {'Authorization': auth,
'X-Auth-Token': 'foo-bar',
'X-Project-Id': 'bar-baz'}
@mock.patch('murano.common.policy.check_is_admin')
@mock.patch('murano.api.v1.cloudfoundry.cfapi._get_muranoclient')

View File

@ -18,6 +18,7 @@ whitelist_externals = bash
[testenv:py34]
commands = python -m testtools.run \
murano/tests/unit/api/middleware/test_ssl.py \
murano/tests/unit/api/v1/cloudfoundry/test_cfapi.py \
murano/tests/unit/cmd/test_engine_workers.py \
murano/tests/unit/common/helpers/test_token_sanitizer.py \
murano/tests/unit/common/test_is_different.py \