Skip to content

Commit

Permalink
Merge branch 'release-0.96.0' into develop
Browse files Browse the repository at this point in the history
* release-0.96.0:
  Bumping version to 0.96.0
  Update elastictranscoder model
  Add test for PendingDeprecationWarnings
  Add pending deprecations to old style interface
  • Loading branch information
AWS committed Mar 19, 2015
2 parents 418ee50 + c995d62 commit c7ad6a8
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 14 deletions.
2 changes: 1 addition & 1 deletion botocore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import re
import logging

__version__ = '0.95.0'
__version__ = '0.96.0'


class NullHandler(logging.Handler):
Expand Down
57 changes: 46 additions & 11 deletions botocore/data/aws/elastictranscoder/2012-09-25.normal.json

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions botocore/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import functools
import logging
import threading
import warnings

from botocore.exceptions import MissingParametersError
from botocore.exceptions import UnknownParameterError
from botocore.exceptions import NoRegionError
Expand Down Expand Up @@ -98,6 +100,8 @@ def _get_signature_version_and_region(self, endpoint, service_model):
return signature_version, endpoint.region_name

def call(self, endpoint, **kwargs):
warnings.warn("call() is deprecated and will be removed. "
"Use clients instead.", PendingDeprecationWarning)
logger.debug("%s called with kwargs: %s", self, kwargs)
# It probably seems a little weird to be firing two different
# events here. The reason is that the first event is fired
Expand Down Expand Up @@ -184,6 +188,9 @@ def pagination(self):

@property
def can_paginate(self):
warnings.warn("can_paginate is deprecated and will be removed. "
"Use client.can_paginate instead.",
PendingDeprecationWarning)
try:
self._load_pagination_config()
except Exception as e:
Expand All @@ -193,12 +200,19 @@ def can_paginate(self):
def paginate(self, endpoint, **kwargs):
"""Iterate over the responses of an operation.
.. warning::
This method is deprecated and will be removed in the
near future. Use ``client.get_paginator`` instead.
This will return an iterator with each element
being a tuple of (``http_response``, ``parsed_response``).
If the operation does not paginate, a ``TypeError`` will
be raised. You can check if an operation can be paginated
by using the ``can_paginate`` arg.
"""
warnings.warn("paginate is deprecated and will be removed. "
"Use client.get_paginator instead.",
PendingDeprecationWarning)
if not self.can_paginate:
raise TypeError("Operation cannot be paginated: %s" % self)
config = self._load_pagination_config()
Expand Down
19 changes: 19 additions & 0 deletions botocore/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# language governing permissions and limitations under the License.

import logging
import warnings

from .endpoint import EndpointCreator
from .operation import Operation
Expand Down Expand Up @@ -134,6 +135,10 @@ def get_endpoint(self, region_name=None, is_secure=True,
Return the Endpoint object for this service in a particular
region.
.. warning::
This method is deprecated and will be removed in the
near future. Use ``Session.create_client`` instead.
:type region_name: str
:param region_name: The name of the region.
Expand All @@ -151,6 +156,8 @@ def get_endpoint(self, region_name=None, is_secure=True,
use in the signature calculation).
"""
warnings.warn("get_endpoint is deprecated and will be removed. "
"Use create_client instead.", PendingDeprecationWarning)
resolver = self.session.get_component('endpoint_resolver')
region = self.session.get_config_variable('region')
event_emitter = self.session.get_component('event_emitter')
Expand All @@ -177,13 +184,18 @@ def get_operation(self, operation_name):
:type operation_name: str
:param operation_name: The name of the operation.
"""
warnings.warn("get_operation is deprecated and will be removed. "
"Use create_client instead.", PendingDeprecationWarning)
for operation in self.operations:
op_names = (operation.name, operation.py_name, operation.cli_name)
if operation_name in op_names:
return operation
return None

def get_waiter(self, waiter_name, endpoint):
warnings.warn("get_waiter is deprecated and will be removed. "
"Use client.get_waiter instead.",
PendingDeprecationWarning)
try:
config = self._load_waiter_config()
except Exception as e:
Expand All @@ -203,11 +215,18 @@ def get_service(session, service_name, provider, api_version=None):
"""
Return a Service object for a given provider name and service name.
.. warning::
This function is deprecated and will be removed in the
near future. Use ``Session.create_client`` instead.
:type service_name: str
:param service_name: The name of the service.
:type provider: Provider
:param provider: The Provider object associated with the session.
"""
warnings.warn("get_service is deprecated and will be removed. "
"Use Session.create_client instead.",
PendingDeprecationWarning)
logger.debug("Creating service object for: %s", service_name)
return Service(session, provider, service_name)
7 changes: 7 additions & 0 deletions botocore/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import os
import platform
import shlex
import warnings

from botocore import __version__
import botocore.config
Expand Down Expand Up @@ -545,11 +546,17 @@ def get_service(self, service_name, api_version=None):
"""
Get information about a service.
.. warning::
This method is deprecated and will be removed in the
near future. Use ``session.create_client`` instead.
:type service_name: str
:param service_name: The name of the service (e.g. 'ec2')
:returns: :class:`botocore.service.Service`
"""
warnings.warn("get_service is deprecated and will be removed. "
"Use create_client instead.", PendingDeprecationWarning)
service = botocore.service.get_service(self, service_name,
self.provider,
api_version=api_version)
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = '0.95'
version = '0.96'
# The full version, including alpha/beta/rc tags.
release = '0.95.0'
release = '0.96.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
58 changes: 58 additions & 0 deletions tests/unit/test_deprecations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file 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 sys
from tests import unittest
import contextlib
import warnings

from nose.tools import assert_equal
from nose.tools import assert_true

import botocore.session


@contextlib.contextmanager
def assert_warns(warning_type, contains=''):
# The warnings module keeps state at the module level.
# In order to give each test a clean slate we need to wipe
# this state out before yielding back to the test.
for v in sys.modules.values():
if getattr(v, '__warningregistry__', None):
v.__warningregistry__ = {}
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
yield
assert_true(len(w) > 0)
assert_equal(w[0].category, warning_type)
if contains:
assert_true(contains in str(w[0].message),
'"%s" not in: %s"' % (contains, w[0].message))


class TestDeprecationsHaveWarnings(unittest.TestCase):
def setUp(self):
self.session = botocore.session.get_session()

def test_get_service_deprecated(self):
with assert_warns(PendingDeprecationWarning, contains='get_service'):
self.session.get_service('cloudformation')

def test_service_get_operation_deprecated(self):
service = self.session.get_service('cloudformation')
with assert_warns(PendingDeprecationWarning, contains='get_operation'):
service.get_operation('ListStacks')

def test_get_endpoint(self):
service = self.session.get_service('cloudformation')
with assert_warns(PendingDeprecationWarning, contains='get_endpoint'):
service.get_endpoint('us-east-1')

0 comments on commit c7ad6a8

Please sign in to comment.