Feilong Wang 57ec3b1dea Fix py35 and pep8
Distil-UI project is depending on distilclient and now there is a py35
gate failure because disticlient doesn't fully support py3.x. This patch
fixes it and adds some test cases to make sure the change won't break
the functions.

Besides, the patch also fixes some pep8 issues by the way.

Change-Id: Ide043d0fca019cd48796669374dc882311e935a1
2017-06-15 03:57:44 +00:00

40 lines
1.5 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import ddt
import mock
from distilclient import client
from distilclient import exceptions
from distilclient.tests.unit import utils
import distilclient.v1.client
import distilclient.v2.client
@ddt.ddt
class ClientTest(utils.TestCase):
@mock.patch("distilclient.v1.client.Client")
def test_init_client_with_string_v1_version(self, mock_client):
mock_client('1', 'foo', auth_url='quuz')
mock_client.assert_called_once_with('1', 'foo', auth_url='quuz')
@mock.patch.object(distilclient.v2.client, 'Client')
def test_init_client_with_string_v2_version(self, mock_client):
mock_client('2', 'foo', auth_url='quuz')
mock_client.assert_called_once_with('2', 'foo', auth_url='quuz')
@ddt.data(None, '', '3', 'v1', 'v2', 'v1.0', 'v2.0')
def test_init_client_with_unsupported_version(self, v):
self.assertRaises(exceptions.VersionNotFoundForAPIMethod,
client.Client, v)