File: test_emr.py

package info (click to toggle)
python-botocore 1.12.103%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 41,552 kB
  • sloc: python: 43,119; xml: 15,052; makefile: 131
file content (68 lines) | stat: -rw-r--r-- 2,659 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright 2014 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.
from tests import unittest

from nose.tools import assert_true

import botocore.session
from botocore.paginate import PageIterator
from botocore.exceptions import OperationNotPageableError


def test_emr_endpoints_work_with_py26():
    # Verify that we can talk to all currently supported EMR endpoints.
    # Python2.6 has an SSL cert bug where it can't read the SAN of
    # certain SSL certs.  We therefore need to always use the CN
    # as the hostname.
    session = botocore.session.get_session()
    for region in ['us-east-1', 'us-west-2', 'us-west-2', 'ap-northeast-1',
                   'ap-southeast-1', 'ap-southeast-2', 'sa-east-1', 'eu-west-1',
                   'eu-central-1']:
        yield _test_can_list_clusters_in_region, session, region


def _test_can_list_clusters_in_region(session, region):
    client = session.create_client('emr', region_name=region)
    response = client.list_clusters()
    assert_true('Clusters' in response)


# I consider these integration tests because they're
# testing more than a single unit, we're ensuring everything
# accessible from the session works as expected.
class TestEMRGetExtraResources(unittest.TestCase):
    def setUp(self):
        self.session = botocore.session.get_session()
        self.client = self.session.create_client('emr', 'us-west-2')

    def test_can_access_pagination_configs(self):
        # Using an operation that we know will paginate.
        paginator = self.client.get_paginator('list_clusters')
        page_iterator = paginator.paginate()
        self.assertIsInstance(page_iterator, PageIterator)

    def test_operation_cant_be_paginated(self):
        with self.assertRaises(OperationNotPageableError):
            self.client.get_paginator('add_instance_groups')

    def test_can_get_waiters(self):
        waiter = self.client.get_waiter('cluster_running')
        self.assertTrue(hasattr(waiter, 'wait'))

    def test_waiter_does_not_exist(self):
        with self.assertRaises(ValueError):
            self.client.get_waiter('does_not_exist')


if __name__ == '__main__':
    unittest.main()