def test_empty_list(self, ec2_client): # pylint: disable=no-self-use with patch("sdcm.utils.common.list_instances_aws", return_value={}) as list_instances_aws: clean_instances_aws({ "TestId": 1111, }) list_instances_aws.assert_called_with(tags_dict={ "TestId": 1111, }, group_as_region=True) ec2_client().terminate_instances.assert_not_called()
def test_sct_runner(self, ec2_client): # pylint: disable=no-self-use with patch("sdcm.utils.common.list_instances_aws", return_value={"eu-north-1": [ SCT_RUNNER_AWS, ]}) as list_instances_aws: clean_instances_aws({ "TestId": 1111, }) list_instances_aws.assert_called_with(tags_dict={ "TestId": 1111, }, group_as_region=True) ec2_client().terminate_instances.assert_not_called()
def test_terminate(self, ec2_client): # pylint: disable=no-self-use with patch("sdcm.utils.common.list_instances_aws", return_value={"eu-north-1": [ { "InstanceId": "i-1111", }, ]}) as list_instances_aws: clean_instances_aws({ "TestId": 1111, }) list_instances_aws.assert_called_with(tags_dict={ "TestId": 1111, }, group_as_region=True) ec2_client().terminate_instances.assert_called_once_with( InstanceIds=["i-1111"])