Use known AMI in internal tests (#3620)

Moto's implementation of autoscaling:CreateLaunchConfiguration is a little too loose,
allowing the ImageId parameter to be omitted and defaulting it to None, which results
in dozens of deprecation warnings:

`PendingDeprecationWarning: Could not find AMI with image-id:ami-123456, in the near future this will cause an error.`

This commit refactors calls to CreateLaunchConfiguration to explicitly pass in a known
AMI ImageId in order to avoid these warnings.

The integrity of the tests is unaffected by this change.
This commit is contained in:
Brian Pandola 2021-01-27 11:49:33 -08:00 committed by GitHub
commit 9e1fcac9d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 162 additions and 47 deletions

View file

@ -10,6 +10,7 @@ from moto import mock_autoscaling_deprecated
from moto import mock_autoscaling
from moto.core import ACCOUNT_ID
from tests.helpers import requires_boto_gte
from tests import EXAMPLE_AMI_ID
@mock_autoscaling_deprecated
@ -207,7 +208,11 @@ def test_launch_configuration_describe_filter():
def test_launch_configuration_describe_paginated():
conn = boto3.client("autoscaling", region_name="us-east-1")
for i in range(51):
conn.create_launch_configuration(LaunchConfigurationName="TestLC%d" % i)
conn.create_launch_configuration(
LaunchConfigurationName="TestLC%d" % i,
ImageId=EXAMPLE_AMI_ID,
InstanceType="t2.medium",
)
response = conn.describe_launch_configurations()
lcs = response["LaunchConfigurations"]