def test_search_for_ecs_details(self, mock_logger, mock_session, event_no_cache): cid = ContainerInstanceDrainer(event_no_cache, None) cid.search_for_ecs_details('dummy-id') cid.ecs_client.get_paginator.assert_any_call('list_clusters') cid.ecs_client.get_paginator.assert_any_call( 'list_container_instances')
def test_get_ecs_details_no_cache(self, mock_logger, mock_session, event_no_cache): cid = ContainerInstanceDrainer(event_no_cache, None) cid.cache = {} expected = ('my_cluster_1', 'my_ci_1') cid.search_for_ecs_details = Mock(return_value=expected) rv = cid.get_ecs_details('dummy') cid.search_for_ecs_details.assert_called_with('dummy') assert rv == expected
def test_get_ecs_details_with_cache(self, mock_logger, mock_session, event_no_cache): cid = ContainerInstanceDrainer(event_no_cache, None) cid.cache = dict(EcsCluster='my_cluster_2', ContainerInstanceArn='my_ci_2') expected = ('my_cluster_2', 'my_ci_2') cid.search_for_ecs_details = Mock() rv = cid.get_ecs_details('dummy') assert rv == expected cid.search_for_ecs_details.assert_not_called()