Remove six usage

Change-Id: I2fab7d64c808c69ad404064a4b547cdfd945c8a7
This commit is contained in:
zhurong 2020-04-16 02:28:20 -07:00
parent a5fb155fb0
commit 2c1a6c2ca0
20 changed files with 60 additions and 81 deletions

View File

@ -16,7 +16,6 @@ import copy
import json
import os
import random
import six
import string
import time
@ -165,7 +164,7 @@ class SolumClient(rest_client.RestClient):
def delete_created_lps(self):
resp, body = self.get('v1/language_packs')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
[self._delete_language_pack(pl['uuid']) for pl in data]
@ -200,7 +199,7 @@ class SolumClient(rest_client.RestClient):
class SolumResponse(object):
def __init__(self, resp, body, body_type):
self.resp = resp
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
self.body = body
if body_type == 'json':

View File

@ -11,7 +11,6 @@
# under the License.
import json
import six
from solum_tempest_plugin import base
@ -26,7 +25,7 @@ class PlatformDiscoveryTestCase(base.TestCase):
request_without_auth('camp/platform_endpoints',
'GET'))
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
endpoints = json.loads(body)
self.assertEqual('platform_endpoints', endpoints['type'])
@ -47,7 +46,7 @@ class PlatformDiscoveryTestCase(base.TestCase):
request_without_auth(rel_ep_url,
'GET'))
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
endpoint = json.loads(body)
self.assertEqual('platform_endpoint', endpoint['type'])

View File

@ -11,7 +11,6 @@
# under the License.
import json
import six
from tempest.lib import exceptions as tempest_exceptions
import yaml
@ -69,7 +68,7 @@ class TestAssembliesController(base.TestCase):
self.assertEqual(200, resp.status, 'GET assemblies resource')
# pick out the assemebly link for our new assembly uuid
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
assemblies_dct = json.loads(body)
camp_link = None
@ -87,7 +86,7 @@ class TestAssembliesController(base.TestCase):
resp, body = self.client.get(url)
self.assertEqual(200, resp.status, msg)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
assembly = json.loads(body)
self.assertEqual('assembly', assembly['type'])

View File

@ -11,7 +11,6 @@
# under the License.
import json
import six
from solum_tempest_plugin import base
@ -28,7 +27,7 @@ class TestSupportedFormats(base.TestCase):
self.skipTest('CAMP not enabled.')
resp, body = self.client.get('camp/v1_1/formats/')
self.assertEqual(200, resp.status, 'GET formats resource')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
formats = json.loads(body)
self.assertEqual('formats', formats['type'])
@ -46,7 +45,7 @@ class TestSupportedFormats(base.TestCase):
# get our lone platform_endpoint resource
resp, body = self.client.get(url)
self.assertEqual(200, resp.status, 'GET JSON format resource')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
formatr = json.loads(body)
self.assertEqual('format', formatr['type'])

View File

@ -11,7 +11,6 @@
# under the License.
import json
import six
from solum_tempest_plugin import base
@ -28,7 +27,7 @@ class TestParameterDefinitions(base.TestCase):
self.skipTest('CAMP not enabled.')
resp, body = self.client.get('camp/v1_1/assemblies/')
self.assertEqual(200, resp.status, 'GET assemblies resource')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
assemblies = json.loads(body)
@ -40,7 +39,7 @@ class TestParameterDefinitions(base.TestCase):
resp, body = self.client.get(url)
self.assertEqual(200, resp.status,
'GET assembly parameter_definitions resource')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
pd_resc = json.loads(body)
self.assertEqual('parameter_definitions', pd_resc['type'])
@ -72,7 +71,7 @@ class TestParameterDefinitions(base.TestCase):
self.skipTest('CAMP not enabled.')
resp, body = self.client.get('camp/v1_1/plans/')
self.assertEqual(200, resp.status, 'GET plans resource')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
plans = json.loads(body)
@ -84,7 +83,7 @@ class TestParameterDefinitions(base.TestCase):
resp, body = self.client.get(url)
self.assertEqual(200, resp.status,
'GET plans parameter_definitions resource')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
pd_resc = json.loads(body)
self.assertEqual('parameter_definitions', pd_resc['type'])

View File

@ -12,7 +12,6 @@
import copy
import json
import six
from tempest.lib import exceptions as tempest_exceptions
import yaml
@ -100,7 +99,7 @@ class TestPlansController(base.TestCase):
self.assertEqual(200, resp.status, 'GET plans resource')
# pick out the plan link for our new plan uuid
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
plans_dct = json.loads(body)
camp_link = None
@ -119,7 +118,7 @@ class TestPlansController(base.TestCase):
self.assertEqual(200, resp.status, msg)
# CAMP plans are rendered in JSON
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
plan = json.loads(body)
self.assertEqual(base.plan_sample_data['name'], plan['name'])
@ -350,7 +349,7 @@ class TestPlansController(base.TestCase):
uri, patch_json,
headers={'content-type': 'application/json-patch+json'})
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self.assertIn('tags', json_data)

View File

@ -11,7 +11,6 @@
# under the License.
import json
import six
from solum_tempest_plugin import base
@ -21,7 +20,7 @@ class TestPlatformAndContainers(base.TestCase):
def _test_get_resource(self, url, rtype, name):
resp, body = self.client.get(url)
self.assertEqual(200, resp.status, 'GET %s resource' % rtype)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
resource = json.loads(body)
self.assertEqual(rtype, resource['type'])
@ -33,7 +32,7 @@ class TestPlatformAndContainers(base.TestCase):
# get and test our platform resource
resp, body = self.client.get('camp/v1_1/platform/')
self.assertEqual(200, resp.status, 'GET platform resource')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
platform = json.loads(body)
self.assertEqual('platform', platform['type'])

View File

@ -11,7 +11,6 @@
# under the License.
import json
import six
from solum_tempest_plugin import base
@ -22,7 +21,7 @@ class TestTypeDefinitions(base.TestCase):
url = abs_url[len(self.client.base_url) + 1:]
resp, body = self.client.get(url)
self.assertEqual(200, resp.status, msg)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
resource = json.loads(body)
self.assertEqual(rtype, resource['type'])
@ -42,7 +41,7 @@ class TestTypeDefinitions(base.TestCase):
resp, body = self.client.get('camp/v1_1/type_definitions')
self.assertEqual(200, resp.status, 'GET type_definitions resource')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
defs_dct = json.loads(body)
for link_dct in defs_dct['type_definition_links']:

View File

@ -14,7 +14,6 @@
# under the License.
import json
import six
from solum_tempest_plugin import base
@ -22,7 +21,7 @@ from solum_tempest_plugin import base
class VersionDiscoveryTestCase(base.TestCase):
def test_get_root_discovers_v1(self):
resp, body = self.client.get('/')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
body = json.loads(body)
self.assertEqual(200, resp.status)
@ -35,7 +34,7 @@ class VersionDiscoveryTestCase(base.TestCase):
def test_delete_root_discovers_v1(self):
resp, body = self.client.delete('/')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
body = json.loads(body)
self.assertEqual(200, resp.status)
@ -48,7 +47,7 @@ class VersionDiscoveryTestCase(base.TestCase):
def test_post_root_discovers_v1(self):
resp, body = self.client.post('/', '{}')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
body = json.loads(body)
self.assertEqual(200, resp.status)
@ -61,7 +60,7 @@ class VersionDiscoveryTestCase(base.TestCase):
def test_put_root_discovers_v1(self):
resp, body = self.client.put('/', '{}')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
body = json.loads(body)
self.assertEqual(200, resp.status)
@ -75,7 +74,7 @@ class VersionDiscoveryTestCase(base.TestCase):
def test_post_no_body_root_discovers_v1(self):
self.skipTest("POST without body will hang request: #1367470")
resp, body = self.client.post('/', None)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
body = json.loads(body)
self.assertEqual(200, resp.status)
@ -89,7 +88,7 @@ class VersionDiscoveryTestCase(base.TestCase):
def test_put_no_body_root_discovers_v1(self):
self.skipTest("PUT without body will hang request: #1367470")
resp, body = self.client.put('/', None)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
body = json.loads(body)
self.assertEqual(200, resp.status)

View File

@ -11,7 +11,6 @@
# under the License.
import json
import six
import time
import requests
@ -28,7 +27,7 @@ class TestTriggerController(base.TestCase):
data = apputils.get_sample_data(languagepack=lp_name)
resp = self.client.create_app(data=data)
body = resp.body
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
bdy = json.loads(body)
trigger_uri = bdy['trigger_uri']
@ -53,7 +52,7 @@ class TestTriggerController(base.TestCase):
data = apputils.get_sample_data(languagepack=lp_name)
resp = self.client.create_app(data=data)
body = resp.body
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
bdy = json.loads(body)
trigger_uri = bdy['trigger_uri']

View File

@ -14,7 +14,6 @@
# under the License.
import json
import six
import time
from tempest.lib import exceptions as tempest_exceptions
@ -99,7 +98,7 @@ class TestAppController(base.TestCase):
headers={'content-type': 'application/json'})
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
app_body = json.loads(body)
self.assertEqual('newfakeappname', app_body["name"])
@ -149,7 +148,7 @@ class TestAppController(base.TestCase):
self.assertEqual(201, create_resp.status)
id = create_resp.id
resp, body = self.client.delete_app(id)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
self.assertEqual(202, resp.status)
self.assertEqual('', body)

View File

@ -14,7 +14,6 @@
# under the License.
import json
import six
from tempest.lib import exceptions as tempest_exceptions
@ -71,7 +70,7 @@ class TestAssemblyController(base.TestCase):
self.assertEqual(200, resp.status)
# Search for uuids of created assemblies
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
assembly_list = json.loads(body)
found_uuid_1 = False
@ -118,7 +117,7 @@ class TestAssemblyController(base.TestCase):
plan_uuid)
resp, body = self.client.get('v1/assemblies/%s' % uuid)
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self._assert_output_expected(json_data, sample_data)
@ -131,7 +130,7 @@ class TestAssemblyController(base.TestCase):
resp, body = self.client.get('v1/assemblies/%s' % uuid,
headers=use_https)
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self._assert_output_expected(json_data, sample_data)
@ -159,7 +158,7 @@ class TestAssemblyController(base.TestCase):
updated_json = json.dumps(updated_data)
resp, body = self.client.put('v1/assemblies/%s' % uuid, updated_json)
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self._assert_output_expected(json_data, updated_data)
@ -213,7 +212,7 @@ class TestAssemblyController(base.TestCase):
uuid = assembly_resp.uuid
resp, body = self.client.delete_assembly(uuid)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
self.assertEqual(204, resp.status)
self.assertEqual('', body)

View File

@ -14,7 +14,6 @@
# under the License.
import json
import six
from tempest.lib import exceptions as tempest_exceptions
@ -63,7 +62,7 @@ class TestComponentController(base.TestCase):
data = json.dumps(sample_data)
resp, body = self.client.post('v1/components', data)
self.assertEqual(201, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
out_data = json.loads(body)
uuid = out_data['uuid']
@ -73,7 +72,7 @@ class TestComponentController(base.TestCase):
def test_components_get_all(self):
uuid, assembly_uuid, plan_uuid = self._create_component()
resp, body = self.client.get('v1/components')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
self.assertEqual(200, resp.status)
@ -96,7 +95,7 @@ class TestComponentController(base.TestCase):
sample_json = json.dumps(sample_data)
resp, body = self.client.post('v1/components', sample_json)
self.assertEqual(201, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self._assert_output_expected(json_data, sample_data)
@ -112,7 +111,7 @@ class TestComponentController(base.TestCase):
plan_uuid)
resp, body = self.client.get('v1/components/%s' % uuid)
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self._assert_output_expected(json_data, sample_data)
@ -132,7 +131,7 @@ class TestComponentController(base.TestCase):
updated_json = json.dumps(updated_data)
resp, body = self.client.put('v1/components/%s' % uuid, updated_json)
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self._assert_output_expected(json_data, updated_data)
@ -156,7 +155,7 @@ class TestComponentController(base.TestCase):
def test_components_delete(self):
uuid, assembly_uuid, plan_uuid = self._create_component()
resp, body = self.client.delete('v1/components/%s' % uuid)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
self.assertEqual(204, resp.status)
self.assertEqual('', body)

View File

@ -14,7 +14,6 @@
# under the License.
import json
import six
from solum_tempest_plugin import base
@ -23,7 +22,7 @@ class TestExtensionController(base.TestCase):
def test_extensions_get_all(self):
resp, body = self.client.get('v1/extensions')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
self.assertEqual(200, resp.status)

View File

@ -14,7 +14,6 @@
import json
import random
import six
import string
import time
@ -46,7 +45,7 @@ class TestLanguagePackController(base.TestCase):
def _delete_all(self):
resp, body = self.client.get('v1/language_packs')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
self.assertEqual(200, resp.status)
@ -61,7 +60,7 @@ class TestLanguagePackController(base.TestCase):
jsondata = json.dumps(sample_lp)
resp, body = self.client.post('v1/language_packs', jsondata)
self.assertEqual(201, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
out_data = json.loads(body)
uuid = out_data['uuid']
@ -71,7 +70,7 @@ class TestLanguagePackController(base.TestCase):
def test_language_packs_get_all(self):
uuid, sample_lp = self._create_language_pack()
resp, body = self.client.get('v1/language_packs')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
self.assertEqual(200, resp.status)
@ -84,7 +83,7 @@ class TestLanguagePackController(base.TestCase):
sample_json = json.dumps(sample_lp)
resp, body = self.client.post('v1/language_packs', sample_json)
self.assertEqual(201, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self.assertEqual("QUEUED", json_data["status"])
@ -99,7 +98,7 @@ class TestLanguagePackController(base.TestCase):
uuid, sample_lp = self._create_language_pack()
resp, body = self.client.get('v1/language_packs/%s' % uuid)
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self.assertEqual(sample_lp['source_uri'], json_data['source_uri'])
@ -113,7 +112,7 @@ class TestLanguagePackController(base.TestCase):
def test_language_packs_delete(self):
uuid, sample_lp = self._create_language_pack()
resp, body = self.client.delete('v1/language_packs/%s' % uuid)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
self.assertEqual(204, resp.status)
self.assertEqual('', body)
@ -149,7 +148,7 @@ class TestLanguagePackController(base.TestCase):
self.assertRaises(tempest_exceptions.Conflict,
self.client.delete, 'v1/language_packs/%s' % uuid)
body = resp.body
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
bdy = json.loads(body)

View File

@ -14,7 +14,6 @@
# under the License.
import json
import six
from solum_tempest_plugin import base
@ -23,7 +22,7 @@ class TestOperationController(base.TestCase):
def test_operations_get_all(self):
resp, body = self.client.get('v1/operations')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
self.assertEqual(200, resp.status)

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from tempest.lib import exceptions as tempest_exceptions
import yaml
@ -226,7 +224,7 @@ class TestPlanController(base.TestCase):
self.assertEqual(201, create_resp.status)
uuid = create_resp.uuid
resp, body = self.client.delete_plan(uuid)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
self.assertEqual(202, resp.status)
self.assertEqual('', body)

View File

@ -14,7 +14,6 @@
# under the License.
import json
import six
from solum_tempest_plugin import base
@ -24,7 +23,7 @@ class TestRootController(base.TestCase):
def test_index(self):
resp, body = self.client.request_without_auth('', 'GET')
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
self.assertEqual(data[0]['id'], 'v1.0')
@ -36,7 +35,7 @@ class TestRootController(base.TestCase):
def test_platform(self):
resp, body = self.client.request_without_auth('v1', 'GET')
self.assertEqual(200, resp.status)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
self.assertEqual(data['uri'], '%s/v1' % self.client.base_url)

View File

@ -14,7 +14,6 @@
# under the License.
import json
import six
from solum_tempest_plugin import base
@ -23,7 +22,7 @@ class TestSensorController(base.TestCase):
def test_sensors_get_all(self):
resp, body = self.client.get('v1/sensors')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
self.assertEqual(200, resp.status)

View File

@ -14,7 +14,6 @@
# under the License.
import json
import six
from tempest.lib import exceptions as tempest_exceptions
@ -36,7 +35,7 @@ class TestServiceController(base.TestCase):
def _delete_all(self):
resp, body = self.client.get('v1/services')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
self.assertEqual(resp.status, 200)
@ -58,7 +57,7 @@ class TestServiceController(base.TestCase):
jsondata = json.dumps(sample_data)
resp, body = self.client.post('v1/services', jsondata)
self.assertEqual(resp.status, 201)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
out_data = json.loads(body)
uuid = out_data['uuid']
@ -68,7 +67,7 @@ class TestServiceController(base.TestCase):
def test_services_get_all(self):
uuid = self._create_service()
resp, body = self.client.get('v1/services')
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
data = json.loads(body)
self.assertEqual(resp.status, 200)
@ -79,7 +78,7 @@ class TestServiceController(base.TestCase):
sample_json = json.dumps(sample_data)
resp, body = self.client.post('v1/services', sample_json)
self.assertEqual(resp.status, 201)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self._assert_output_expected(json_data, sample_data)
@ -93,7 +92,7 @@ class TestServiceController(base.TestCase):
uuid = self._create_service()
resp, body = self.client.get('v1/services/%s' % uuid)
self.assertEqual(resp.status, 200)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self._assert_output_expected(json_data, sample_data)
@ -113,7 +112,7 @@ class TestServiceController(base.TestCase):
updated_json = json.dumps(updated_data)
resp, body = self.client.put('v1/services/%s' % uuid, updated_json)
self.assertEqual(resp.status, 200)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
json_data = json.loads(body)
self._assert_output_expected(json_data, updated_data)
@ -137,7 +136,7 @@ class TestServiceController(base.TestCase):
def test_services_delete(self):
uuid = self._create_service()
resp, body = self.client.delete('v1/services/%s' % uuid)
if isinstance(body, six.binary_type):
if isinstance(body, bytes):
body = body.decode('utf-8')
self.assertEqual(resp.status, 204)
self.assertEqual(body, '')