Skip to content

Commit

Permalink
PR #64 - fix logic error - calling function on function
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Sep 30, 2015
1 parent 68dcc96 commit e342771
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion awslimitchecker/services/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 8 additions & 5 deletions awslimitchecker/tests/services/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit e342771

Please sign in to comment.