Merge "pre-commit: Bump mypy"

This commit is contained in:
Zuul 2024-09-12 22:25:32 +00:00 committed by Gerrit Code Review
commit 9172a043a3
48 changed files with 317 additions and 121 deletions

View File

@ -37,7 +37,7 @@ repos:
- flake8-import-order~=0.18.2
exclude: '^(doc|releasenotes|tools)/.*$'
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.1
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies:

View File

@ -64,6 +64,8 @@ class AcceleratorRequest(resource.Resource):
has_body=True,
retry_on_conflict=None,
base_path=None,
*,
microversion=None,
):
# This overrides the default behavior of patch because
# the PATCH method consumes a dict rather than a list. spec:
@ -104,7 +106,7 @@ class AcceleratorRequest(resource.Resource):
attrs = attrs[self.resources_key][0]
return super()._consume_attrs(mapping, attrs)
def create(self, session, base_path=None):
def create(self, session, prepend_key=False, *args, **kwargs):
# This overrides the default behavior of resource creation because
# cyborg doesn't accept resource_key in its request.
return super().create(session, prepend_key=False, base_path=base_path)
return super().create(session, prepend_key, *args, **kwargs)

View File

@ -38,11 +38,19 @@ class DeviceProfile(resource.Resource):
# TODO(s_shogo): This implementation only treat [ DeviceProfile ], and
# cannot treat multiple DeviceProfiles in list.
def _prepare_request_body(self, patch, prepend_key):
body = super()._prepare_request_body(patch, prepend_key)
def _prepare_request_body(
self,
patch,
prepend_key,
*,
resource_request_key=None,
):
body = super()._prepare_request_body(
patch, prepend_key, resource_request_key=resource_request_key
)
return [body]
def create(self, session, base_path=None):
def create(self, session, prepend_key=False, *args, **kwargs):
# This overrides the default behavior of resource creation because
# cyborg doesn't accept resource_key in its request.
return super().create(session, prepend_key=False, base_path=base_path)
return super().create(session, prepend_key, *args, **kwargs)

View File

@ -1465,6 +1465,8 @@ class Node(_common.Resource):
has_body=True,
retry_on_conflict=None,
base_path=None,
*,
microversion=None,
reset_interfaces=None,
):
if reset_interfaces is not None:

View File

@ -60,7 +60,7 @@ class Group(resource.Resource):
exceptions.raise_from_response(response)
return response
def delete(self, session, *, delete_volumes=False):
def delete(self, session, *args, delete_volumes=False, **kwargs):
"""Delete a group."""
body = {'delete': {'delete-volumes': delete_volumes}}
self._action(session, body)

View File

@ -90,11 +90,12 @@ class Service(resource.Resource):
f"No {cls.__name__} found for {name_or_id}"
)
def commit(self, session, prepend_key=False, **kwargs):
def commit(self, session, prepend_key=False, *args, **kwargs):
# we need to set prepend_key to false
return super().commit(
session,
prepend_key=prepend_key,
prepend_key,
*args,
**kwargs,
)

View File

@ -359,7 +359,9 @@ class Volume(resource.Resource, metadata.MetadataMixin):
self._action(session, body)
def _prepare_request_body(self, patch, prepend_key):
def _prepare_request_body(
self, patch, prepend_key, *, resource_request_key=None
):
body = self._body.dirty
# Scheduler hints is external to the standard volume request
# so pass it separately and not under the volume JSON object.

View File

@ -16,7 +16,7 @@ from openstack import resource
class AsyncResource(resource.Resource):
def delete(self, session, error_message=None):
def delete(self, session, error_message=None, **kwargs):
"""Delete the remote resource based on this instance.
:param session: The session to use for making this request.

View File

@ -55,17 +55,31 @@ class QuotaSet(resource.Resource):
requires_id=False,
base_path=None,
error_message=None,
skip_cache=False,
*,
resource_response_key=None,
microversion=None,
**params,
):
return super().fetch(
session,
requires_id=False,
base_path=base_path,
error_message=error_message,
requires_id,
base_path,
error_message,
skip_cache,
resource_response_key=resource_response_key,
microversion=microversion,
**params,
)
def _translate_response(self, response, has_body=None, error_message=None):
def _translate_response(
self,
response,
has_body=None,
error_message=None,
*,
resource_response_key=None,
):
"""Given a KSA response, inflate this instance with its data
DELETE operations don't return a body, so only try to work
@ -127,7 +141,13 @@ class QuotaSet(resource.Resource):
self._update_location()
dict.update(self, self.to_dict())
def _prepare_request_body(self, patch, prepend_key):
def _prepare_request_body(
self,
patch,
prepend_key,
*,
resource_request_key=None,
):
body = self._body.dirty
# Ensure we never try to send meta props reservation and usage
body.pop('reservation', None)

View File

@ -52,7 +52,7 @@ class TagMixin:
self._body.attributes.update({'tags': json['tags']})
return self
def set_tags(self, session, tags=[]):
def set_tags(self, session, tags):
"""Sets/Replaces all tags on the resource.
:param session: The session to use for making this request.

View File

@ -121,8 +121,8 @@ class Limits(resource.Resource):
self,
session,
requires_id=False,
error_message=None,
base_path=None,
error_message=None,
skip_cache=False,
**params,
):
@ -137,10 +137,10 @@ class Limits(resource.Resource):
# TODO(mordred) We shouldn't have to subclass just to declare
# requires_id = False.
return super().fetch(
session=session,
requires_id=requires_id,
error_message=error_message,
base_path=base_path,
skip_cache=skip_cache,
session,
requires_id,
error_message,
base_path,
skip_cache,
**params,
)

View File

@ -280,13 +280,18 @@ class Server(resource.Resource, metadata.MetadataMixin, tag.TagMixin):
self,
requires_id=True,
prepend_key=True,
patch=False,
base_path=None,
params=None,
**kwargs,
):
request = super()._prepare_request(
requires_id=requires_id,
prepend_key=prepend_key,
patch=patch,
base_path=base_path,
params=params,
**kwargs,
)
server_body = request.body[self.resource_key]

View File

@ -87,13 +87,9 @@ class Service(resource.Resource):
f"No {cls.__name__} found for {name_or_id}"
)
def commit(self, session, prepend_key=False, **kwargs):
def commit(self, session, prepend_key=False, *args, **kwargs):
# we need to set prepend_key to false
return super().commit(
session,
prepend_key=prepend_key,
**kwargs,
)
return super().commit(session, prepend_key, *args, **kwargs)
def _action(self, session, action, body, microversion=None):
if not microversion:

View File

@ -35,7 +35,13 @@ class User(resource.Resource):
password = resource.Body('password')
def _prepare_request(
self, requires_id=True, prepend_key=True, base_path=None, **kwargs
self,
requires_id=True,
prepend_key=True,
patch=False,
base_path=None,
*args,
**kwargs,
):
"""Prepare a request for the database service's create call

View File

@ -51,7 +51,7 @@ class ZoneExport(_base.Resource):
#: ID for the zone that was created by this export
zone_id = resource.Body('zone_id')
def create(self, session, prepend_key=True, base_path=None):
def create(self, session, prepend_key=True, base_path=None, **kwargs):
"""Create a remote resource based on this instance.
:param session: The session to use for making this request.

View File

@ -51,7 +51,7 @@ class ZoneImport(_base.Resource):
#: ID for the zone that was created by this import
zone_id = resource.Body('zone_id')
def create(self, session, prepend_key=True, base_path=None):
def create(self, session, prepend_key=True, base_path=None, **kwargs):
"""Create a remote resource based on this instance.
:param session: The session to use for making this request.

View File

@ -47,7 +47,13 @@ class Limit(resource.Resource):
#: ID of project. *Type: string*
project_id = resource.Body('project_id')
def _prepare_request_body(self, patch, prepend_key):
def _prepare_request_body(
self,
patch,
prepend_key,
*,
resource_request_key=None,
):
body = self._body.dirty
if prepend_key and self.resource_key is not None:
if patch:

View File

@ -45,7 +45,13 @@ class RegisteredLimit(resource.Resource):
#: The default limit value. *Type: int*
default_limit = resource.Body('default_limit')
def _prepare_request_body(self, patch, prepend_key):
def _prepare_request_body(
self,
patch,
prepend_key,
*,
resource_request_key=None,
):
body = self._body.dirty
if prepend_key and self.resource_key is not None:
if patch:

View File

@ -54,7 +54,9 @@ class Cache(resource.Resource):
exceptions.raise_from_response(response)
return response
def clear(self, session, target='both'):
# FIXME(stephenfin): This needs to be renamed as it conflicts with
# dict.clear
def clear(self, session, target='both'): # type: ignore[override]
"""Clears the cache.
:param session: The session to use for making this request
:param target: Specify which target you want to clear

View File

@ -383,6 +383,7 @@ class Image(resource.Resource, tag.TagMixin, _download.DownloadMixin):
prepend_key=False,
patch=False,
base_path=None,
params=None,
**kwargs,
):
request = super()._prepare_request(
@ -390,6 +391,8 @@ class Image(resource.Resource, tag.TagMixin, _download.DownloadMixin):
prepend_key=prepend_key,
patch=patch,
base_path=base_path,
params=params,
**kwargs,
)
if patch:
headers = {

View File

@ -91,6 +91,7 @@ class Secret(resource.Resource):
base_path=None,
error_message=None,
skip_cache=False,
**kwargs,
):
request = self._prepare_request(
requires_id=requires_id, base_path=base_path

View File

@ -111,10 +111,12 @@ class AmphoraConfig(resource.Resource):
#: The ID of the amphora.
amphora_id = resource.URI('amphora_id')
# The default _update code path also has no
# way to pass has_body into this function, so overriding the method here.
def commit(self, session, base_path=None):
return super().commit(session, base_path=base_path, has_body=False)
# The default _update code path also has no way to pass has_body into this
# function, so overriding the method here.
def commit(
self, session, prepend_key=True, has_body=False, *args, **kwargs
):
return super().commit(session, prepend_key, has_body, *args, *kwargs)
class AmphoraFailover(resource.Resource):
@ -134,7 +136,9 @@ class AmphoraFailover(resource.Resource):
#: The ID of the amphora.
amphora_id = resource.URI('amphora_id')
# The default _update code path also has no
# way to pass has_body into this function, so overriding the method here.
def commit(self, session, base_path=None):
return super().commit(session, base_path=base_path, has_body=False)
# The default _update code path also has no way to pass has_body into this
# function, so overriding the method here.
def commit(
self, session, prepend_key=True, has_body=False, *args, **kwargs
):
return super().commit(session, prepend_key, has_body, *args, *kwargs)

View File

@ -83,7 +83,7 @@ class LoadBalancer(resource.Resource, tag.TagMixin):
#: Additional VIPs
additional_vips = resource.Body('additional_vips', type=list)
def delete(self, session, error_message=None):
def delete(self, session, error_message=None, **kwargs):
request = self._prepare_request()
params = {}
if (
@ -145,5 +145,7 @@ class LoadBalancerFailover(resource.Resource):
# The default _update code path also has no
# way to pass has_body into this function, so overriding the method here.
def commit(self, session, base_path=None):
return super().commit(session, base_path=base_path, has_body=False)
def commit(
self, session, prepend_key=True, has_body=False, *args, **kwargs
):
return super().commit(session, prepend_key, has_body, *args, **kwargs)

View File

@ -42,7 +42,13 @@ class Quota(resource.Resource):
project_id = resource.Body('project_id', alternate_id=True)
def _prepare_request(
self, requires_id=True, base_path=None, prepend_key=False, **kwargs
self,
requires_id=True,
prepend_key=False,
patch=False,
base_path=None,
*args,
**kwargs,
):
_request = super()._prepare_request(
requires_id, prepend_key, base_path=base_path

View File

@ -55,13 +55,25 @@ class Claim(resource.Resource):
#: authentication is not enabled in Zaqar service.
project_id = resource.Header("X-PROJECT-ID")
def _translate_response(self, response, has_body=True):
super()._translate_response(response, has_body=has_body)
def _translate_response(
self,
response,
has_body=None,
error_message=None,
*,
resource_response_key=None,
):
super()._translate_response(
response,
has_body,
error_message,
resource_response_key=resource_response_key,
)
if has_body and self.location:
# Extract claim ID from location
self.id = self.location.split("claims/")[1]
def create(self, session, prepend_key=False, base_path=None):
def create(self, session, prepend_key=False, base_path=None, **kwargs):
request = self._prepare_request(
requires_id=False, prepend_key=prepend_key, base_path=base_path
)
@ -89,6 +101,7 @@ class Claim(resource.Resource):
base_path=None,
error_message=None,
skip_cache=False,
**kwargs,
):
request = self._prepare_request(
requires_id=requires_id, base_path=base_path
@ -107,7 +120,13 @@ class Claim(resource.Resource):
return self
def commit(
self, session, prepend_key=False, has_body=False, base_path=None
self,
session,
prepend_key=True,
has_body=True,
retry_on_conflict=None,
base_path=None,
**kwargs,
):
request = self._prepare_request(
prepend_key=prepend_key, base_path=base_path
@ -122,7 +141,7 @@ class Claim(resource.Resource):
return self
def delete(self, session):
def delete(self, session, *args, **kwargs):
request = self._prepare_request()
headers = {
"Client-ID": self.client_id or str(uuid.uuid4()),

View File

@ -123,6 +123,7 @@ class Message(resource.Resource):
base_path=None,
error_message=None,
skip_cache=False,
**kwargs,
):
request = self._prepare_request(
requires_id=requires_id, base_path=base_path
@ -140,7 +141,9 @@ class Message(resource.Resource):
return self
def delete(self, session):
def delete(
self, session, error_message=None, *, microversion=None, **kwargs
):
request = self._prepare_request()
headers = {
"Client-ID": self.client_id or str(uuid.uuid4()),

View File

@ -50,7 +50,7 @@ class Queue(resource.Resource):
#: in case keystone auth is not enabled in Zaqar service.
project_id = resource.Header("X-PROJECT-ID")
def create(self, session, prepend_key=True, base_path=None):
def create(self, session, prepend_key=False, base_path=None, **kwargs):
request = self._prepare_request(
requires_id=True, prepend_key=prepend_key, base_path=None
)
@ -117,6 +117,7 @@ class Queue(resource.Resource):
base_path=None,
error_message=None,
skip_cache=False,
**kwargs,
):
request = self._prepare_request(
requires_id=requires_id, base_path=base_path
@ -133,7 +134,9 @@ class Queue(resource.Resource):
return self
def delete(self, session):
def delete(
self, session, error_message=None, *, microversion=None, **kwargs
):
request = self._prepare_request()
headers = {
"Client-ID": self.client_id or str(uuid.uuid4()),

View File

@ -58,7 +58,7 @@ class Subscription(resource.Resource):
#: authentication is not enabled in Zaqar service.
project_id = resource.Header("X-PROJECT-ID")
def create(self, session, prepend_key=True, base_path=None):
def create(self, session, prepend_key=False, base_path=None, **kwargs):
request = self._prepare_request(
requires_id=False, prepend_key=prepend_key, base_path=base_path
)
@ -125,6 +125,7 @@ class Subscription(resource.Resource):
base_path=None,
error_message=None,
skip_cache=False,
**kwargs,
):
request = self._prepare_request(
requires_id=requires_id, base_path=base_path
@ -142,7 +143,9 @@ class Subscription(resource.Resource):
return self
def delete(self, session):
def delete(
self, session, error_message=None, *, microversion=None, **kwargs
):
request = self._prepare_request()
headers = {
"Client-ID": self.client_id or str(uuid.uuid4()),

View File

@ -25,6 +25,7 @@ class NetworkResource(resource.Resource):
patch=False,
base_path=None,
params=None,
*,
if_revision=None,
**kwargs,
):

View File

@ -61,7 +61,13 @@ class Quota(resource.Resource):
security_groups = resource.Body('security_group', type=int)
def _prepare_request(
self, requires_id=True, prepend_key=False, base_path=None, **kwargs
self,
requires_id=True,
prepend_key=False,
patch=False,
base_path=None,
*args,
**kwargs,
):
_request = super()._prepare_request(requires_id, prepend_key)
if self.resource_key in _request.body:

View File

@ -40,8 +40,8 @@ class BaseResource(resource.Resource):
else:
self.metadata[k] = v
def _prepare_request(self, **kwargs):
request = super()._prepare_request(**kwargs)
def _prepare_request(self, *args, **kwargs):
request = super()._prepare_request(*args, **kwargs)
request.headers.update(self._calculate_headers(self.metadata))
return request
@ -91,7 +91,14 @@ class BaseResource(resource.Resource):
key = header[len(self._custom_metadata_prefix) :].lower()
self.metadata[key] = headers[header]
def _translate_response(self, response, has_body=None, error_message=None):
def _translate_response(
self,
response,
has_body=None,
error_message=None,
*,
resource_response_key=None,
):
# Save headers of the last operation for potential use (get_object of
# cloud layer).
# This must happen before invoking parent _translate_response, cause it

View File

@ -12,6 +12,7 @@
from calendar import timegm
import collections
import functools
from hashlib import sha1
import hmac
import json
@ -56,6 +57,7 @@ class Proxy(proxy.Proxy):
log = _log.setup_logging('openstack')
@functools.lru_cache(maxsize=256)
def _extract_name(self, url, service_type=None, project_id=None):
url_path = parse.urlparse(url).path.strip()
# Remove / from the beginning to keep the list indexes of interesting

View File

@ -123,7 +123,7 @@ class Container(_base.BaseResource):
kwargs.setdefault('name', name)
return cls(_synchronized=False, **kwargs)
def create(self, session, prepend_key=True, base_path=None):
def create(self, session, prepend_key=True, base_path=None, **kwargs):
"""Create a remote resource based on this instance.
:param session: The session to use for making this request.

View File

@ -12,7 +12,7 @@
# under the License.
import re
import urllib
import urllib.parse
from openstack import exceptions
from openstack import resource
@ -58,8 +58,9 @@ class Info(resource.Resource):
session,
requires_id=False,
base_path=None,
skip_cache=False,
error_message=None,
skip_cache=False,
**kwargs,
):
"""Get a remote resource based on this instance.

View File

@ -213,7 +213,7 @@ class Object(_base.BaseResource):
# The Object Store treats the metadata for its resources inconsistently so
# Object.set_metadata must override the BaseResource.set_metadata to
# account for it.
def set_metadata(self, session, metadata):
def set_metadata(self, session, metadata, refresh=True):
# Filter out items with empty values so the create metadata behaviour
# is the same as account and container
filtered_metadata = {
@ -321,7 +321,7 @@ class Object(_base.BaseResource):
)
return response.iter_content(chunk_size, decode_unicode=False)
def create(self, session, base_path=None, **params):
def create(self, session, prepend_key=True, base_path=None, **kwargs):
request = self._prepare_request(base_path=base_path)
response = session.put(
@ -330,11 +330,11 @@ class Object(_base.BaseResource):
self._translate_response(response, has_body=False)
return self
def _raw_delete(self, session, microversion=None):
def _raw_delete(self, session, microversion=None, **kwargs):
if not self.allow_delete:
raise exceptions.MethodNotSupported(self, "delete")
raise exceptions.MethodNotSupported(self, 'delete')
request = self._prepare_request()
request = self._prepare_request(**kwargs)
session = self._get_session(session)
if microversion is None:
microversion = self._get_microversion(session, action='delete')
@ -349,5 +349,7 @@ class Object(_base.BaseResource):
headers['multipart-manifest'] = 'delete'
return session.delete(
request.url, headers=headers, microversion=microversion
request.url,
headers=headers,
microversion=microversion,
)

View File

@ -45,7 +45,7 @@ class SoftwareConfig(resource.Resource):
#: produces.
outputs = resource.Body('outputs')
def create(self, session, base_path=None):
def create(self, session, prepend_key=False, *args, **kwargs):
# This overrides the default behavior of resource creation because
# heat doesn't accept resource_key in its request.
return super().create(session, prepend_key=False, base_path=base_path)
return super().create(session, prepend_key, *args, **kwargs)

View File

@ -49,12 +49,12 @@ class SoftwareDeployment(resource.Resource):
#: The date and time when the software deployment resource was created.
updated_at = resource.Body('updated_time')
def create(self, session, base_path=None):
def create(self, session, prepend_key=False, *args, **kwargs):
# This overrides the default behavior of resource creation because
# heat doesn't accept resource_key in its request.
return super().create(session, prepend_key=False, base_path=base_path)
return super().create(session, prepend_key, *args, **kwargs)
def commit(self, session, base_path=None):
def commit(self, session, prepend_key=False, *args, **kwargs):
# This overrides the default behavior of resource creation because
# heat doesn't accept resource_key in its request.
return super().commit(session, prepend_key=False, base_path=base_path)
return super().commit(session, prepend_key, *args, **kwargs)

View File

@ -112,10 +112,10 @@ class Stack(resource.Resource):
#: The ID of the user project created for this stack.
user_project_id = resource.Body('stack_user_project_id')
def create(self, session, base_path=None):
def create(self, session, prepend_key=False, *args, **kwargs):
# This overrides the default behavior of resource creation because
# heat doesn't accept resource_key in its request.
return super().create(session, prepend_key=False, base_path=base_path)
return super().create(session, prepend_key, *args, **kwargs)
def commit(
self,
@ -219,7 +219,9 @@ class Stack(resource.Resource):
base_path=None,
error_message=None,
skip_cache=False,
*,
resolve_outputs=True,
**params,
):
if not self.allow_fetch:
raise exceptions.MethodNotSupported(self, "fetch")

View File

@ -33,7 +33,9 @@ class StackFiles(resource.Resource):
# Backwards compat
stack_id = id # type: ignore
def fetch(self, session, base_path=None):
def fetch(
self, session, requires_id=False, base_path=None, *args, **kwargs
):
# The stack files response contains a map of filenames and file
# contents.
request = self._prepare_request(requires_id=False, base_path=base_path)

View File

@ -73,9 +73,10 @@ class ShareAccessRule(resource.Resource):
url, json=body, headers=headers, microversion=microversion
)
def create(self, session, **kwargs):
def create(self, session, *args, **kwargs):
return super().create(
session,
*args,
resource_request_key='allow_access',
resource_response_key='access',
**kwargs,

View File

@ -55,7 +55,13 @@ class ShareNetworkSubnet(resource.Resource):
#: Date and time the share network subnet was last updated at.
updated_at = resource.Body("updated_at", type=str)
def create(self, session, **kwargs):
def create(
self,
session,
*args,
resource_request_key='share-network-subnet',
**kwargs,
):
return super().create(
session, resource_request_key='share-network-subnet', **kwargs
session, resource_request_key=resource_request_key, *args, **kwargs
)

View File

@ -498,10 +498,16 @@ class TestQuotaSet(TestVolumeProxy):
'openstack.resource.Resource.fetch',
self.proxy.get_quota_set,
method_args=['prj'],
expected_args=[self.proxy],
expected_args=[
self.proxy,
False,
None,
None,
False,
],
expected_kwargs={
'error_message': None,
'requires_id': False,
'microversion': None,
'resource_response_key': None,
'usage': False,
},
method_result=quota_set.QuotaSet(),
@ -514,10 +520,16 @@ class TestQuotaSet(TestVolumeProxy):
self.proxy.get_quota_set,
method_args=['prj'],
method_kwargs={'usage': True, 'user_id': 'uid'},
expected_args=[self.proxy],
expected_args=[
self.proxy,
False,
None,
None,
False,
],
expected_kwargs={
'error_message': None,
'requires_id': False,
'microversion': None,
'resource_response_key': None,
'usage': True,
'user_id': 'uid',
},
@ -528,11 +540,16 @@ class TestQuotaSet(TestVolumeProxy):
'openstack.resource.Resource.fetch',
self.proxy.get_quota_set_defaults,
method_args=['prj'],
expected_args=[self.proxy],
expected_args=[
self.proxy,
False,
'/os-quota-sets/defaults',
None,
False,
],
expected_kwargs={
'error_message': None,
'requires_id': False,
'base_path': '/os-quota-sets/defaults',
'microversion': None,
'resource_response_key': None,
},
)

View File

@ -971,10 +971,16 @@ class TestQuotaSet(TestVolumeProxy):
'openstack.resource.Resource.fetch',
self.proxy.get_quota_set,
method_args=['prj'],
expected_args=[self.proxy],
expected_args=[
self.proxy,
False,
None,
None,
False,
],
expected_kwargs={
'error_message': None,
'requires_id': False,
'microversion': None,
'resource_response_key': None,
'usage': False,
},
method_result=quota_set.QuotaSet(),
@ -987,10 +993,16 @@ class TestQuotaSet(TestVolumeProxy):
self.proxy.get_quota_set,
method_args=['prj'],
method_kwargs={'usage': True, 'user_id': 'uid'},
expected_args=[self.proxy],
expected_args=[
self.proxy,
False,
None,
None,
False,
],
expected_kwargs={
'error_message': None,
'requires_id': False,
'microversion': None,
'resource_response_key': None,
'usage': True,
'user_id': 'uid',
},
@ -1001,11 +1013,16 @@ class TestQuotaSet(TestVolumeProxy):
'openstack.resource.Resource.fetch',
self.proxy.get_quota_set_defaults,
method_args=['prj'],
expected_args=[self.proxy],
expected_args=[
self.proxy,
False,
'/os-quota-sets/defaults',
None,
False,
],
expected_kwargs={
'error_message': None,
'requires_id': False,
'base_path': '/os-quota-sets/defaults',
'microversion': None,
'resource_response_key': None,
},
)

View File

@ -1654,10 +1654,16 @@ class TestQuotaSet(TestComputeProxy):
'openstack.resource.Resource.fetch',
self.proxy.get_quota_set,
method_args=['prj'],
expected_args=[self.proxy],
expected_args=[
self.proxy,
False,
None,
None,
False,
],
expected_kwargs={
'error_message': None,
'requires_id': False,
'microversion': None,
'resource_response_key': None,
},
method_result=quota_set.QuotaSet(),
expected_result=quota_set.QuotaSet(),
@ -1669,12 +1675,17 @@ class TestQuotaSet(TestComputeProxy):
self.proxy.get_quota_set,
method_args=['prj'],
method_kwargs={'usage': True, 'user_id': 'uid'},
expected_args=[self.proxy],
expected_args=[
self.proxy,
False,
'/os-quota-sets/%(project_id)s/detail',
None,
False,
],
expected_kwargs={
'error_message': None,
'requires_id': False,
'microversion': None,
'resource_response_key': None,
'user_id': 'uid',
'base_path': '/os-quota-sets/%(project_id)s/detail',
},
)
@ -1683,11 +1694,16 @@ class TestQuotaSet(TestComputeProxy):
'openstack.resource.Resource.fetch',
self.proxy.get_quota_set_defaults,
method_args=['prj'],
expected_args=[self.proxy],
expected_args=[
self.proxy,
False,
'/os-quota-sets/%(project_id)s/defaults',
None,
False,
],
expected_kwargs={
'error_message': None,
'requires_id': False,
'base_path': '/os-quota-sets/%(project_id)s/defaults',
'microversion': None,
'resource_response_key': None,
},
)

View File

@ -183,9 +183,7 @@ class TestStack(base.TestCase):
res = sot.create(sess)
mock_create.assert_called_once_with(
sess, prepend_key=False, base_path=None
)
mock_create.assert_called_once_with(sess, False)
self.assertEqual(mock_create.return_value, res)
def test_check(self):

View File

@ -71,5 +71,11 @@ class CronTrigger(resource.Resource):
#: The time at which the cron trigger was created
updated_at = resource.Body("updated_at")
def create(self, session, base_path=None):
return super().create(session, prepend_key=False, base_path=base_path)
def create(
self,
session,
prepend_key=False,
*args,
**kwargs,
):
return super().create(session, prepend_key, *args, **kwargs)

View File

@ -58,7 +58,13 @@ class Execution(resource.Resource):
#: The time at which the Execution was updated
updated_at = resource.Body("updated_at")
def create(self, session, prepend_key=True, base_path=None):
def create(
self,
session,
prepend_key=True,
base_path=None,
**kwargs,
):
request = self._prepare_request(
requires_id=False, prepend_key=prepend_key, base_path=base_path
)

View File

@ -64,7 +64,13 @@ class Workflow(resource.Resource):
request.headers.update(headers)
return dict(url=uri, json=None, headers=request.headers, **kwargs)
def create(self, session, prepend_key=True, base_path=None):
def create(
self,
session,
prepend_key=True,
base_path=None,
**kwargs,
):
kwargs = self._request_kwargs(
prepend_key=prepend_key, base_path=base_path
)