Blacken openstackclient.api
Black used with the '-l 79 -S' flags. A future change will ignore this commit in git-blame history by adding a 'git-blame-ignore-revs' file. Change-Id: I1df5bc4c35f02147fe5ac5b4073f0e01e7d51c2f Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
7d80f9e962
commit
a6f81a736c
@ -30,12 +30,7 @@ class KeystoneSession(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(self, session=None, endpoint=None, **kwargs):
|
||||||
self,
|
|
||||||
session=None,
|
|
||||||
endpoint=None,
|
|
||||||
**kwargs
|
|
||||||
):
|
|
||||||
"""Base object that contains some common API objects and methods
|
"""Base object that contains some common API objects and methods
|
||||||
|
|
||||||
:param Session session:
|
:param Session session:
|
||||||
@ -87,11 +82,7 @@ class BaseAPI(KeystoneSession):
|
|||||||
"""Base API"""
|
"""Base API"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self, session=None, service_type=None, endpoint=None, **kwargs
|
||||||
session=None,
|
|
||||||
service_type=None,
|
|
||||||
endpoint=None,
|
|
||||||
**kwargs
|
|
||||||
):
|
):
|
||||||
"""Base object that contains some common API objects and methods
|
"""Base object that contains some common API objects and methods
|
||||||
|
|
||||||
@ -110,13 +101,7 @@ class BaseAPI(KeystoneSession):
|
|||||||
|
|
||||||
# The basic action methods all take a Session and return dict/lists
|
# The basic action methods all take a Session and return dict/lists
|
||||||
|
|
||||||
def create(
|
def create(self, url, session=None, method=None, **params):
|
||||||
self,
|
|
||||||
url,
|
|
||||||
session=None,
|
|
||||||
method=None,
|
|
||||||
**params
|
|
||||||
):
|
|
||||||
"""Create a new resource
|
"""Create a new resource
|
||||||
|
|
||||||
:param string url:
|
:param string url:
|
||||||
@ -136,12 +121,7 @@ class BaseAPI(KeystoneSession):
|
|||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def delete(
|
def delete(self, url, session=None, **params):
|
||||||
self,
|
|
||||||
url,
|
|
||||||
session=None,
|
|
||||||
**params
|
|
||||||
):
|
|
||||||
"""Delete a resource
|
"""Delete a resource
|
||||||
|
|
||||||
:param string url:
|
:param string url:
|
||||||
@ -152,14 +132,7 @@ class BaseAPI(KeystoneSession):
|
|||||||
|
|
||||||
return self._request('DELETE', url, **params)
|
return self._request('DELETE', url, **params)
|
||||||
|
|
||||||
def list(
|
def list(self, path, session=None, body=None, detailed=False, **params):
|
||||||
self,
|
|
||||||
path,
|
|
||||||
session=None,
|
|
||||||
body=None,
|
|
||||||
detailed=False,
|
|
||||||
**params
|
|
||||||
):
|
|
||||||
"""Return a list of resources
|
"""Return a list of resources
|
||||||
|
|
||||||
GET ${ENDPOINT}/${PATH}?${PARAMS}
|
GET ${ENDPOINT}/${PATH}?${PARAMS}
|
||||||
@ -255,9 +228,7 @@ class BaseAPI(KeystoneSession):
|
|||||||
if len(data) > 1:
|
if len(data) > 1:
|
||||||
msg = _("Multiple %(resource)s exist with %(attr)s='%(value)s'")
|
msg = _("Multiple %(resource)s exist with %(attr)s='%(value)s'")
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
msg % {'resource': resource,
|
msg % {'resource': resource, 'attr': attr, 'value': value}
|
||||||
'attr': attr,
|
|
||||||
'value': value}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Search by id
|
# Search by id
|
||||||
@ -267,16 +238,10 @@ class BaseAPI(KeystoneSession):
|
|||||||
return data[0]
|
return data[0]
|
||||||
msg = _("No %(resource)s with a %(attr)s or ID of '%(value)s' found")
|
msg = _("No %(resource)s with a %(attr)s or ID of '%(value)s' found")
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
msg % {'resource': resource,
|
msg % {'resource': resource, 'attr': attr, 'value': value}
|
||||||
'attr': attr,
|
|
||||||
'value': value}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def find_bulk(
|
def find_bulk(self, path, **kwargs):
|
||||||
self,
|
|
||||||
path,
|
|
||||||
**kwargs
|
|
||||||
):
|
|
||||||
"""Bulk load and filter locally
|
"""Bulk load and filter locally
|
||||||
|
|
||||||
:param string path:
|
:param string path:
|
||||||
@ -302,11 +267,7 @@ class BaseAPI(KeystoneSession):
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def find_one(
|
def find_one(self, path, **kwargs):
|
||||||
self,
|
|
||||||
path,
|
|
||||||
**kwargs
|
|
||||||
):
|
|
||||||
"""Find a resource by name or ID
|
"""Find a resource by name or ID
|
||||||
|
|
||||||
:param string path:
|
:param string path:
|
||||||
|
@ -22,6 +22,7 @@ from osc_lib.i18n import _
|
|||||||
# TODO(dtroyer): Mingrate this to osc-lib
|
# TODO(dtroyer): Mingrate this to osc-lib
|
||||||
class InvalidValue(Exception):
|
class InvalidValue(Exception):
|
||||||
"""An argument value is not valid: wrong type, out of range, etc"""
|
"""An argument value is not valid: wrong type, out of range, etc"""
|
||||||
|
|
||||||
message = "Supplied value is not valid"
|
message = "Supplied value is not valid"
|
||||||
|
|
||||||
|
|
||||||
@ -291,11 +292,7 @@ class APIv2(api.BaseAPI):
|
|||||||
return self.list(url)["hosts"]
|
return self.list(url)["hosts"]
|
||||||
|
|
||||||
def host_set(
|
def host_set(
|
||||||
self,
|
self, host=None, status=None, maintenance_mode=None, **params
|
||||||
host=None,
|
|
||||||
status=None,
|
|
||||||
maintenance_mode=None,
|
|
||||||
**params
|
|
||||||
):
|
):
|
||||||
"""Modify host properties
|
"""Modify host properties
|
||||||
|
|
||||||
@ -576,7 +573,7 @@ class APIv2(api.BaseAPI):
|
|||||||
value=security_group,
|
value=security_group,
|
||||||
)
|
)
|
||||||
if security_group is not None:
|
if security_group is not None:
|
||||||
for (k, v) in params.items():
|
for k, v in params.items():
|
||||||
# Only set a value if it is already present
|
# Only set a value if it is already present
|
||||||
if k in security_group:
|
if k in security_group:
|
||||||
security_group[k] = v
|
security_group[k] = v
|
||||||
|
@ -33,11 +33,7 @@ class APIv1(api.BaseAPI):
|
|||||||
self.endpoint = self.endpoint + self._endpoint_suffix
|
self.endpoint = self.endpoint + self._endpoint_suffix
|
||||||
|
|
||||||
def image_list(
|
def image_list(
|
||||||
self,
|
self, detailed=False, public=False, private=False, **filter
|
||||||
detailed=False,
|
|
||||||
public=False,
|
|
||||||
private=False,
|
|
||||||
**filter
|
|
||||||
):
|
):
|
||||||
"""Get available images
|
"""Get available images
|
||||||
|
|
||||||
|
@ -36,10 +36,7 @@ class APIv1(api.BaseAPI):
|
|||||||
super(APIv1, self).__init__(**kwargs)
|
super(APIv1, self).__init__(**kwargs)
|
||||||
|
|
||||||
def container_create(
|
def container_create(
|
||||||
self,
|
self, container=None, public=False, storage_policy=None
|
||||||
container=None,
|
|
||||||
public=False,
|
|
||||||
storage_policy=None
|
|
||||||
):
|
):
|
||||||
"""Create a container
|
"""Create a container
|
||||||
|
|
||||||
@ -62,7 +59,8 @@ class APIv1(api.BaseAPI):
|
|||||||
headers['x-storage-policy'] = storage_policy
|
headers['x-storage-policy'] = storage_policy
|
||||||
|
|
||||||
response = self.create(
|
response = self.create(
|
||||||
urllib.parse.quote(container), method='PUT', headers=headers)
|
urllib.parse.quote(container), method='PUT', headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'account': self._find_account_id(),
|
'account': self._find_account_id(),
|
||||||
@ -192,9 +190,7 @@ class APIv1(api.BaseAPI):
|
|||||||
data = {
|
data = {
|
||||||
'account': self._find_account_id(),
|
'account': self._find_account_id(),
|
||||||
'container': container,
|
'container': container,
|
||||||
'object_count': response.headers.get(
|
'object_count': response.headers.get('x-container-object-count'),
|
||||||
'x-container-object-count'
|
|
||||||
),
|
|
||||||
'bytes_used': response.headers.get('x-container-bytes-used'),
|
'bytes_used': response.headers.get('x-container-bytes-used'),
|
||||||
'storage_policy': response.headers.get('x-storage-policy'),
|
'storage_policy': response.headers.get('x-storage-policy'),
|
||||||
}
|
}
|
||||||
@ -208,8 +204,9 @@ class APIv1(api.BaseAPI):
|
|||||||
if 'x-container-sync-key' in response.headers:
|
if 'x-container-sync-key' in response.headers:
|
||||||
data['sync_key'] = response.headers.get('x-container-sync-key')
|
data['sync_key'] = response.headers.get('x-container-sync-key')
|
||||||
|
|
||||||
properties = self._get_properties(response.headers,
|
properties = self._get_properties(
|
||||||
'x-container-meta-')
|
response.headers, 'x-container-meta-'
|
||||||
|
)
|
||||||
if properties:
|
if properties:
|
||||||
data['properties'] = properties
|
data['properties'] = properties
|
||||||
|
|
||||||
@ -228,8 +225,9 @@ class APIv1(api.BaseAPI):
|
|||||||
properties to remove from the container
|
properties to remove from the container
|
||||||
"""
|
"""
|
||||||
|
|
||||||
headers = self._unset_properties(properties,
|
headers = self._unset_properties(
|
||||||
'X-Remove-Container-Meta-%s')
|
properties, 'X-Remove-Container-Meta-%s'
|
||||||
|
)
|
||||||
if headers:
|
if headers:
|
||||||
self.create(urllib.parse.quote(container), headers=headers)
|
self.create(urllib.parse.quote(container), headers=headers)
|
||||||
|
|
||||||
@ -259,8 +257,10 @@ class APIv1(api.BaseAPI):
|
|||||||
# object's name in the container.
|
# object's name in the container.
|
||||||
object_name_str = name if name else object
|
object_name_str = name if name else object
|
||||||
|
|
||||||
full_url = "%s/%s" % (urllib.parse.quote(container),
|
full_url = "%s/%s" % (
|
||||||
urllib.parse.quote(object_name_str))
|
urllib.parse.quote(container),
|
||||||
|
urllib.parse.quote(object_name_str),
|
||||||
|
)
|
||||||
with io.open(object, 'rb') as f:
|
with io.open(object, 'rb') as f:
|
||||||
response = self.create(
|
response = self.create(
|
||||||
full_url,
|
full_url,
|
||||||
@ -293,8 +293,10 @@ class APIv1(api.BaseAPI):
|
|||||||
if container is None or object is None:
|
if container is None or object is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.delete("%s/%s" % (urllib.parse.quote(container),
|
self.delete(
|
||||||
urllib.parse.quote(object)))
|
"%s/%s"
|
||||||
|
% (urllib.parse.quote(container), urllib.parse.quote(object))
|
||||||
|
)
|
||||||
|
|
||||||
def object_list(
|
def object_list(
|
||||||
self,
|
self,
|
||||||
@ -394,8 +396,8 @@ class APIv1(api.BaseAPI):
|
|||||||
|
|
||||||
response = self._request(
|
response = self._request(
|
||||||
'GET',
|
'GET',
|
||||||
"%s/%s" % (urllib.parse.quote(container),
|
"%s/%s"
|
||||||
urllib.parse.quote(object)),
|
% (urllib.parse.quote(container), urllib.parse.quote(object)),
|
||||||
stream=True,
|
stream=True,
|
||||||
)
|
)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
@ -429,9 +431,11 @@ class APIv1(api.BaseAPI):
|
|||||||
|
|
||||||
headers = self._set_properties(properties, 'X-Object-Meta-%s')
|
headers = self._set_properties(properties, 'X-Object-Meta-%s')
|
||||||
if headers:
|
if headers:
|
||||||
self.create("%s/%s" % (urllib.parse.quote(container),
|
self.create(
|
||||||
urllib.parse.quote(object)),
|
"%s/%s"
|
||||||
headers=headers)
|
% (urllib.parse.quote(container), urllib.parse.quote(object)),
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
def object_unset(
|
def object_unset(
|
||||||
self,
|
self,
|
||||||
@ -451,9 +455,11 @@ class APIv1(api.BaseAPI):
|
|||||||
|
|
||||||
headers = self._unset_properties(properties, 'X-Remove-Object-Meta-%s')
|
headers = self._unset_properties(properties, 'X-Remove-Object-Meta-%s')
|
||||||
if headers:
|
if headers:
|
||||||
self.create("%s/%s" % (urllib.parse.quote(container),
|
self.create(
|
||||||
urllib.parse.quote(object)),
|
"%s/%s"
|
||||||
headers=headers)
|
% (urllib.parse.quote(container), urllib.parse.quote(object)),
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
def object_show(
|
def object_show(
|
||||||
self,
|
self,
|
||||||
@ -473,9 +479,11 @@ class APIv1(api.BaseAPI):
|
|||||||
if container is None or object is None:
|
if container is None or object is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
response = self._request('HEAD', "%s/%s" %
|
response = self._request(
|
||||||
(urllib.parse.quote(container),
|
'HEAD',
|
||||||
urllib.parse.quote(object)))
|
"%s/%s"
|
||||||
|
% (urllib.parse.quote(container), urllib.parse.quote(object)),
|
||||||
|
)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'account': self._find_account_id(),
|
'account': self._find_account_id(),
|
||||||
@ -484,9 +492,7 @@ class APIv1(api.BaseAPI):
|
|||||||
'content-type': response.headers.get('content-type'),
|
'content-type': response.headers.get('content-type'),
|
||||||
}
|
}
|
||||||
if 'content-length' in response.headers:
|
if 'content-length' in response.headers:
|
||||||
data['content-length'] = response.headers.get(
|
data['content-length'] = response.headers.get('content-length')
|
||||||
'content-length'
|
|
||||||
)
|
|
||||||
if 'last-modified' in response.headers:
|
if 'last-modified' in response.headers:
|
||||||
data['last-modified'] = response.headers.get('last-modified')
|
data['last-modified'] = response.headers.get('last-modified')
|
||||||
if 'etag' in response.headers:
|
if 'etag' in response.headers:
|
||||||
@ -549,8 +555,9 @@ class APIv1(api.BaseAPI):
|
|||||||
properties to remove from the account
|
properties to remove from the account
|
||||||
"""
|
"""
|
||||||
|
|
||||||
headers = self._unset_properties(properties,
|
headers = self._unset_properties(
|
||||||
'X-Remove-Account-Meta-%s')
|
properties, 'X-Remove-Account-Meta-%s'
|
||||||
|
)
|
||||||
if headers:
|
if headers:
|
||||||
self.create("", headers=headers)
|
self.create("", headers=headers)
|
||||||
|
|
||||||
@ -596,5 +603,5 @@ class APIv1(api.BaseAPI):
|
|||||||
properties = {}
|
properties = {}
|
||||||
for k, v in headers.items():
|
for k, v in headers.items():
|
||||||
if k.lower().startswith(header_tag):
|
if k.lower().startswith(header_tag):
|
||||||
properties[k[len(header_tag):]] = v
|
properties[k[len(header_tag) :]] = v
|
||||||
return properties
|
return properties
|
||||||
|
@ -47,7 +47,6 @@ LIST_BODY = {
|
|||||||
|
|
||||||
|
|
||||||
class TestSession(utils.TestCase):
|
class TestSession(utils.TestCase):
|
||||||
|
|
||||||
BASE_URL = 'https://api.example.com:1234/vX'
|
BASE_URL = 'https://api.example.com:1234/vX'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -20,7 +20,6 @@ from openstackclient.tests.unit.api import fakes as api_fakes
|
|||||||
|
|
||||||
|
|
||||||
class TestKeystoneSession(api_fakes.TestSession):
|
class TestKeystoneSession(api_fakes.TestSession):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestKeystoneSession, self).setUp()
|
super(TestKeystoneSession, self).setUp()
|
||||||
self.api = api.KeystoneSession(
|
self.api = api.KeystoneSession(
|
||||||
@ -40,7 +39,6 @@ class TestKeystoneSession(api_fakes.TestSession):
|
|||||||
|
|
||||||
|
|
||||||
class TestBaseAPI(api_fakes.TestSession):
|
class TestBaseAPI(api_fakes.TestSession):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestBaseAPI, self).setUp()
|
super(TestBaseAPI, self).setUp()
|
||||||
self.api = api.BaseAPI(
|
self.api = api.BaseAPI(
|
||||||
@ -80,7 +78,6 @@ class TestBaseAPI(api_fakes.TestSession):
|
|||||||
# find tests
|
# find tests
|
||||||
|
|
||||||
def test_find_attr_by_id(self):
|
def test_find_attr_by_id(self):
|
||||||
|
|
||||||
# All first requests (by name) will fail in this test
|
# All first requests (by name) will fail in this test
|
||||||
self.requests_mock.register_uri(
|
self.requests_mock.register_uri(
|
||||||
'GET',
|
'GET',
|
||||||
@ -172,7 +169,6 @@ class TestBaseAPI(api_fakes.TestSession):
|
|||||||
self.assertEqual(api_fakes.RESP_ITEM_1, ret)
|
self.assertEqual(api_fakes.RESP_ITEM_1, ret)
|
||||||
|
|
||||||
def test_find_attr_path_resource(self):
|
def test_find_attr_path_resource(self):
|
||||||
|
|
||||||
# Test resource different than path
|
# Test resource different than path
|
||||||
self.requests_mock.register_uri(
|
self.requests_mock.register_uri(
|
||||||
'GET',
|
'GET',
|
||||||
|
@ -26,7 +26,6 @@ FAKE_URL = 'http://gopher.com/v2'
|
|||||||
|
|
||||||
|
|
||||||
class TestComputeAPIv2(utils.TestCase):
|
class TestComputeAPIv2(utils.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestComputeAPIv2, self).setUp()
|
super(TestComputeAPIv2, self).setUp()
|
||||||
sess = session.Session()
|
sess = session.Session()
|
||||||
@ -35,18 +34,17 @@ class TestComputeAPIv2(utils.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestFloatingIP(TestComputeAPIv2):
|
class TestFloatingIP(TestComputeAPIv2):
|
||||||
|
|
||||||
FAKE_FLOATING_IP_RESP = {
|
FAKE_FLOATING_IP_RESP = {
|
||||||
'id': 1,
|
'id': 1,
|
||||||
'ip': '203.0.113.11', # TEST-NET-3
|
'ip': '203.0.113.11', # TEST-NET-3
|
||||||
'fixed_ip': '198.51.100.11', # TEST-NET-2
|
'fixed_ip': '198.51.100.11', # TEST-NET-2
|
||||||
'pool': 'nova',
|
'pool': 'nova',
|
||||||
'instance_id': None,
|
'instance_id': None,
|
||||||
}
|
}
|
||||||
FAKE_FLOATING_IP_RESP_2 = {
|
FAKE_FLOATING_IP_RESP_2 = {
|
||||||
'id': 2,
|
'id': 2,
|
||||||
'ip': '203.0.113.12', # TEST-NET-3
|
'ip': '203.0.113.12', # TEST-NET-3
|
||||||
'fixed_ip': '198.51.100.12', # TEST-NET-2
|
'fixed_ip': '198.51.100.12', # TEST-NET-2
|
||||||
'pool': 'nova',
|
'pool': 'nova',
|
||||||
'instance_id': None,
|
'instance_id': None,
|
||||||
}
|
}
|
||||||
@ -213,7 +211,6 @@ class TestFloatingIP(TestComputeAPIv2):
|
|||||||
|
|
||||||
|
|
||||||
class TestFloatingIPPool(TestComputeAPIv2):
|
class TestFloatingIPPool(TestComputeAPIv2):
|
||||||
|
|
||||||
LIST_FLOATING_IP_POOL_RESP = [
|
LIST_FLOATING_IP_POOL_RESP = [
|
||||||
{"name": "tide"},
|
{"name": "tide"},
|
||||||
{"name": "press"},
|
{"name": "press"},
|
||||||
@ -231,7 +228,6 @@ class TestFloatingIPPool(TestComputeAPIv2):
|
|||||||
|
|
||||||
|
|
||||||
class TestHost(TestComputeAPIv2):
|
class TestHost(TestComputeAPIv2):
|
||||||
|
|
||||||
FAKE_HOST_RESP_1 = {
|
FAKE_HOST_RESP_1 = {
|
||||||
"zone": "internal",
|
"zone": "internal",
|
||||||
"host_name": "myhost",
|
"host_name": "myhost",
|
||||||
@ -340,7 +336,6 @@ class TestHost(TestComputeAPIv2):
|
|||||||
|
|
||||||
|
|
||||||
class TestNetwork(TestComputeAPIv2):
|
class TestNetwork(TestComputeAPIv2):
|
||||||
|
|
||||||
FAKE_NETWORK_RESP = {
|
FAKE_NETWORK_RESP = {
|
||||||
'id': '1',
|
'id': '1',
|
||||||
'label': 'label1',
|
'label': 'label1',
|
||||||
@ -491,20 +486,19 @@ class TestNetwork(TestComputeAPIv2):
|
|||||||
|
|
||||||
|
|
||||||
class TestSecurityGroup(TestComputeAPIv2):
|
class TestSecurityGroup(TestComputeAPIv2):
|
||||||
|
|
||||||
FAKE_SECURITY_GROUP_RESP = {
|
FAKE_SECURITY_GROUP_RESP = {
|
||||||
'id': '1',
|
'id': '1',
|
||||||
'name': 'sg1',
|
'name': 'sg1',
|
||||||
'description': 'test security group',
|
'description': 'test security group',
|
||||||
'tenant_id': '0123456789',
|
'tenant_id': '0123456789',
|
||||||
'rules': []
|
'rules': [],
|
||||||
}
|
}
|
||||||
FAKE_SECURITY_GROUP_RESP_2 = {
|
FAKE_SECURITY_GROUP_RESP_2 = {
|
||||||
'id': '2',
|
'id': '2',
|
||||||
'name': 'sg2',
|
'name': 'sg2',
|
||||||
'description': 'another test security group',
|
'description': 'another test security group',
|
||||||
'tenant_id': '0123456789',
|
'tenant_id': '0123456789',
|
||||||
'rules': []
|
'rules': [],
|
||||||
}
|
}
|
||||||
LIST_SECURITY_GROUP_RESP = [
|
LIST_SECURITY_GROUP_RESP = [
|
||||||
FAKE_SECURITY_GROUP_RESP_2,
|
FAKE_SECURITY_GROUP_RESP_2,
|
||||||
@ -656,8 +650,8 @@ class TestSecurityGroup(TestComputeAPIv2):
|
|||||||
status_code=200,
|
status_code=200,
|
||||||
)
|
)
|
||||||
ret = self.api.security_group_set(
|
ret = self.api.security_group_set(
|
||||||
security_group='1',
|
security_group='1', description='desc2'
|
||||||
description='desc2')
|
)
|
||||||
self.assertEqual(self.FAKE_SECURITY_GROUP_RESP, ret)
|
self.assertEqual(self.FAKE_SECURITY_GROUP_RESP, ret)
|
||||||
|
|
||||||
def test_security_group_set_options_name(self):
|
def test_security_group_set_options_name(self):
|
||||||
@ -679,13 +673,12 @@ class TestSecurityGroup(TestComputeAPIv2):
|
|||||||
status_code=200,
|
status_code=200,
|
||||||
)
|
)
|
||||||
ret = self.api.security_group_set(
|
ret = self.api.security_group_set(
|
||||||
security_group='sg2',
|
security_group='sg2', description='desc2'
|
||||||
description='desc2')
|
)
|
||||||
self.assertEqual(self.FAKE_SECURITY_GROUP_RESP_2, ret)
|
self.assertEqual(self.FAKE_SECURITY_GROUP_RESP_2, ret)
|
||||||
|
|
||||||
|
|
||||||
class TestSecurityGroupRule(TestComputeAPIv2):
|
class TestSecurityGroupRule(TestComputeAPIv2):
|
||||||
|
|
||||||
FAKE_SECURITY_GROUP_RULE_RESP = {
|
FAKE_SECURITY_GROUP_RULE_RESP = {
|
||||||
'id': '1',
|
'id': '1',
|
||||||
'name': 'sgr1',
|
'name': 'sgr1',
|
||||||
|
@ -25,7 +25,6 @@ FAKE_URL = 'http://gopher.dev10.com'
|
|||||||
|
|
||||||
|
|
||||||
class TestImageAPIv1(utils.TestCase):
|
class TestImageAPIv1(utils.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestImageAPIv1, self).setUp()
|
super(TestImageAPIv1, self).setUp()
|
||||||
|
|
||||||
@ -35,7 +34,6 @@ class TestImageAPIv1(utils.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestImage(TestImageAPIv1):
|
class TestImage(TestImageAPIv1):
|
||||||
|
|
||||||
PUB_PROT = {
|
PUB_PROT = {
|
||||||
'id': '1',
|
'id': '1',
|
||||||
'name': 'pub1',
|
'name': 'pub1',
|
||||||
|
@ -25,7 +25,6 @@ FAKE_URL = 'http://gopher.dev20.com'
|
|||||||
|
|
||||||
|
|
||||||
class TestImageAPIv2(utils.TestCase):
|
class TestImageAPIv2(utils.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestImageAPIv2, self).setUp()
|
super(TestImageAPIv2, self).setUp()
|
||||||
|
|
||||||
@ -35,7 +34,6 @@ class TestImageAPIv2(utils.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestImage(TestImageAPIv2):
|
class TestImage(TestImageAPIv2):
|
||||||
|
|
||||||
PUB_PROT = {
|
PUB_PROT = {
|
||||||
'id': '1',
|
'id': '1',
|
||||||
'name': 'pub1',
|
'name': 'pub1',
|
||||||
|
@ -30,10 +30,18 @@ FAKE_CONTAINER = 'rainbarrel'
|
|||||||
FAKE_OBJECT = 'spigot'
|
FAKE_OBJECT = 'spigot'
|
||||||
|
|
||||||
LIST_CONTAINER_RESP = [
|
LIST_CONTAINER_RESP = [
|
||||||
{"name": "qaz", "count": 0, "bytes": 0,
|
{
|
||||||
"last_modified": "2020-05-16T05:52:07.377550"},
|
"name": "qaz",
|
||||||
{"name": "fred", "count": 0, "bytes": 0,
|
"count": 0,
|
||||||
"last_modified": "2020-05-16T05:55:07.377550"},
|
"bytes": 0,
|
||||||
|
"last_modified": "2020-05-16T05:52:07.377550",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fred",
|
||||||
|
"count": 0,
|
||||||
|
"bytes": 0,
|
||||||
|
"last_modified": "2020-05-16T05:55:07.377550",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
LIST_OBJECT_RESP = [
|
LIST_OBJECT_RESP = [
|
||||||
@ -43,7 +51,6 @@ LIST_OBJECT_RESP = [
|
|||||||
|
|
||||||
|
|
||||||
class TestObjectAPIv1(utils.TestCase):
|
class TestObjectAPIv1(utils.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestObjectAPIv1, self).setUp()
|
super(TestObjectAPIv1, self).setUp()
|
||||||
sess = session.Session()
|
sess = session.Session()
|
||||||
@ -52,7 +59,6 @@ class TestObjectAPIv1(utils.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestContainer(TestObjectAPIv1):
|
class TestContainer(TestObjectAPIv1):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestContainer, self).setUp()
|
super(TestContainer, self).setUp()
|
||||||
|
|
||||||
@ -128,15 +134,17 @@ class TestContainer(TestObjectAPIv1):
|
|||||||
)
|
)
|
||||||
self.requests_mock.register_uri(
|
self.requests_mock.register_uri(
|
||||||
'GET',
|
'GET',
|
||||||
FAKE_URL +
|
FAKE_URL
|
||||||
'?marker=%s&limit=1&format=json' % LIST_CONTAINER_RESP[0]['name'],
|
+ '?marker=%s&limit=1&format=json'
|
||||||
|
% LIST_CONTAINER_RESP[0]['name'],
|
||||||
json=[LIST_CONTAINER_RESP[1]],
|
json=[LIST_CONTAINER_RESP[1]],
|
||||||
status_code=200,
|
status_code=200,
|
||||||
)
|
)
|
||||||
self.requests_mock.register_uri(
|
self.requests_mock.register_uri(
|
||||||
'GET',
|
'GET',
|
||||||
FAKE_URL +
|
FAKE_URL
|
||||||
'?marker=%s&limit=1&format=json' % LIST_CONTAINER_RESP[1]['name'],
|
+ '?marker=%s&limit=1&format=json'
|
||||||
|
% LIST_CONTAINER_RESP[1]['name'],
|
||||||
json=[],
|
json=[],
|
||||||
status_code=200,
|
status_code=200,
|
||||||
)
|
)
|
||||||
@ -151,7 +159,7 @@ class TestContainer(TestObjectAPIv1):
|
|||||||
'X-Container-Meta-Owner': FAKE_ACCOUNT,
|
'X-Container-Meta-Owner': FAKE_ACCOUNT,
|
||||||
'x-container-object-count': '1',
|
'x-container-object-count': '1',
|
||||||
'x-container-bytes-used': '577',
|
'x-container-bytes-used': '577',
|
||||||
'x-storage-policy': 'o1--sr-r3'
|
'x-storage-policy': 'o1--sr-r3',
|
||||||
}
|
}
|
||||||
resp = {
|
resp = {
|
||||||
'account': FAKE_ACCOUNT,
|
'account': FAKE_ACCOUNT,
|
||||||
@ -172,7 +180,6 @@ class TestContainer(TestObjectAPIv1):
|
|||||||
|
|
||||||
|
|
||||||
class TestObject(TestObjectAPIv1):
|
class TestObject(TestObjectAPIv1):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestObject, self).setUp()
|
super(TestObject, self).setUp()
|
||||||
|
|
||||||
@ -209,7 +216,7 @@ class TestObject(TestObjectAPIv1):
|
|||||||
|
|
||||||
def test_object_create(self):
|
def test_object_create(self):
|
||||||
self.base_object_create('111\n222\n333\n')
|
self.base_object_create('111\n222\n333\n')
|
||||||
self.base_object_create(bytes([0x31, 0x00, 0x0d, 0x0a, 0x7f, 0xff]))
|
self.base_object_create(bytes([0x31, 0x00, 0x0D, 0x0A, 0x7F, 0xFF]))
|
||||||
|
|
||||||
def test_object_delete(self):
|
def test_object_delete(self):
|
||||||
self.requests_mock.register_uri(
|
self.requests_mock.register_uri(
|
||||||
@ -274,35 +281,35 @@ class TestObject(TestObjectAPIv1):
|
|||||||
)
|
)
|
||||||
self.assertEqual(LIST_CONTAINER_RESP, ret)
|
self.assertEqual(LIST_CONTAINER_RESP, ret)
|
||||||
|
|
||||||
# def test_list_objects_full_listing(self):
|
# def test_list_objects_full_listing(self):
|
||||||
# sess = self.app.client_manager.session
|
# sess = self.app.client_manager.session
|
||||||
#
|
#
|
||||||
# def side_effect(*args, **kwargs):
|
# def side_effect(*args, **kwargs):
|
||||||
# rv = sess.get().json.return_value
|
# rv = sess.get().json.return_value
|
||||||
# sess.get().json.return_value = []
|
# sess.get().json.return_value = []
|
||||||
# sess.get().json.side_effect = None
|
# sess.get().json.side_effect = None
|
||||||
# return rv
|
# return rv
|
||||||
#
|
#
|
||||||
# resp = [{'name': 'is-name'}]
|
# resp = [{'name': 'is-name'}]
|
||||||
# sess.get().json.return_value = resp
|
# sess.get().json.return_value = resp
|
||||||
# sess.get().json.side_effect = side_effect
|
# sess.get().json.side_effect = side_effect
|
||||||
#
|
#
|
||||||
# data = lib_object.list_objects(
|
# data = lib_object.list_objects(
|
||||||
# sess,
|
# sess,
|
||||||
# fake_url,
|
# fake_url,
|
||||||
# fake_container,
|
# fake_container,
|
||||||
# full_listing=True,
|
# full_listing=True,
|
||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
# # Check expected values
|
# # Check expected values
|
||||||
# sess.get.assert_called_with(
|
# sess.get.assert_called_with(
|
||||||
# fake_url + '/' + fake_container,
|
# fake_url + '/' + fake_container,
|
||||||
# params={
|
# params={
|
||||||
# 'format': 'json',
|
# 'format': 'json',
|
||||||
# 'marker': 'is-name',
|
# 'marker': 'is-name',
|
||||||
# }
|
# }
|
||||||
# )
|
# )
|
||||||
# self.assertEqual(resp, data)
|
# self.assertEqual(resp, data)
|
||||||
|
|
||||||
def test_object_show(self):
|
def test_object_show(self):
|
||||||
headers = {
|
headers = {
|
||||||
@ -323,8 +330,7 @@ class TestObject(TestObjectAPIv1):
|
|||||||
'content-length': '577',
|
'content-length': '577',
|
||||||
'last-modified': '20130101',
|
'last-modified': '20130101',
|
||||||
'etag': 'qaz',
|
'etag': 'qaz',
|
||||||
'properties': {'wife': 'Wilma',
|
'properties': {'wife': 'Wilma', 'Husband': 'fred'},
|
||||||
'Husband': 'fred'},
|
|
||||||
}
|
}
|
||||||
self.requests_mock.register_uri(
|
self.requests_mock.register_uri(
|
||||||
'HEAD',
|
'HEAD',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user