diff options
author | JordonPhillips <phjordon@amazon.com> | 2017-06-02 16:24:58 -0700 |
---|---|---|
committer | JordonPhillips <phjordon@amazon.com> | 2017-06-02 16:29:57 -0700 |
commit | efe789f69a9501962a0e738e020a02fb6d11ae19 (patch) | |
tree | 766347fc450443ac5a30b34a571e74d3db80e771 /tests | |
parent | af045f93d70fbb4cdac2a8e57d040ce59935d45b (diff) | |
download | boto-efe789f69a9501962a0e738e020a02fb6d11ae19.tar.gz |
Use RegionInfo by default with heuristics
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_connect_to_region.py | 12 | ||||
-rw-r--r-- | tests/unit/test_regioninfo.py | 11 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit/test_connect_to_region.py b/tests/unit/test_connect_to_region.py index f7944b32..5f28112f 100644 --- a/tests/unit/test_connect_to_region.py +++ b/tests/unit/test_connect_to_region.py @@ -19,6 +19,8 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +import os + from tests.unit import unittest @@ -191,6 +193,16 @@ class TestDynamodb2Connection(unittest.TestCase): self.assertIsInstance(connection, DynamoDBConnection) self.assertEqual(connection.host, 'dynamodb.us-east-1.amazonaws.com') + def test_connect_to_unkown_region(self): + from boto.dynamodb2 import connect_to_region + from boto.dynamodb2.layer1 import DynamoDBConnection + os.environ['BOTO_USE_ENDPOINT_HEURISTICS'] = 'True' + connection = connect_to_region( + 'us-east-45', aws_access_key_id='foo', + aws_secret_access_key='bar') + self.assertIsInstance(connection, DynamoDBConnection) + self.assertEqual(connection.host, 'dynamodb.us-east-45.amazonaws.com') + class TestEC2Connection(unittest.TestCase): def test_connect_to_region(self): diff --git a/tests/unit/test_regioninfo.py b/tests/unit/test_regioninfo.py index cff52be8..da73cb9b 100644 --- a/tests/unit/test_regioninfo.py +++ b/tests/unit/test_regioninfo.py @@ -200,6 +200,17 @@ class TestConnectToRegion(unittest.TestCase): expected_endpoint = 'ec2.us-southeast-43.amazonaws.com' self.assertEqual(connection.region.endpoint, expected_endpoint) + def test_connect_with_hueristics_without_explicit_regioninfo(self): + os.environ['BOTO_USE_ENDPOINT_HEURISTICS'] = 'True' + self.addCleanup(os.environ.pop, 'BOTO_USE_ENDPOINT_HEURISTICS') + connection = connect( + 'ec2', 'us-southeast-43', connection_cls=FakeConn) + self.assertIsNotNone(connection) + self.assertIsInstance(connection.region, RegionInfo) + self.assertEqual(connection.region.name, 'us-southeast-43') + expected_endpoint = 'ec2.us-southeast-43.amazonaws.com' + self.assertEqual(connection.region.endpoint, expected_endpoint) + if __name__ == '__main__': unittest.main() |