From e34277106fbd1392795e73bda9463bb281d6e126 Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Wed, 30 Sep 2015 09:52:32 -0400 Subject: [PATCH] PR #64 - fix logic error - calling function on function --- awslimitchecker/services/base.py | 2 +- awslimitchecker/tests/services/test_base.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/awslimitchecker/services/base.py b/awslimitchecker/services/base.py index a7fbf0bd..094b0694 100644 --- a/awslimitchecker/services/base.py +++ b/awslimitchecker/services/base.py @@ -173,7 +173,7 @@ def connect_via(self, driver): else: logger.debug("Connecting to %s (%s)", self.service_name, self.region) - conn = driver.connect_to_region(self.region) + conn = driver(self.region) logger.info("Connected to %s", self.service_name) return conn diff --git a/awslimitchecker/tests/services/test_base.py b/awslimitchecker/tests/services/test_base.py index b6863fed..26e30a71 100644 --- a/awslimitchecker/tests/services/test_base.py +++ b/awslimitchecker/tests/services/test_base.py @@ -276,18 +276,21 @@ def test_connect_via_no_region(self): mock_driver = Mock() res = cls.connect_via(mock_driver) assert mock_driver.mock_calls == [ - call.connect_to_region(None) + call(None) ] - assert res == mock_driver.connect_to_region.return_value + assert res == mock_driver.return_value def test_connect_via_with_region(self): cls = AwsServiceTester(1, 2, region='foo') mock_driver = Mock() - res = cls.connect_via(mock_driver) + with patch('awslimitchecker.services.base._AwsService.' + '_get_sts_token') as mock_get_sts: + res = cls.connect_via(mock_driver) + assert mock_get_sts.mock_calls == [] assert mock_driver.mock_calls == [ - call.connect_to_region('foo') + call('foo') ] - assert res == mock_driver.connect_to_region.return_value + assert res == mock_driver.return_value def test_connect_via_sts(self): cls = AwsServiceTester(1, 2, account_id='123', account_role='myrole',