コード例 #1
0
  def testGetSuggestedInstancesTwoDifferentSize(self, getAutoScalingGroupsMock):
    region = "us-west-2"
    # Instance 1
    instanceMock1 = Mock(spec="boto.ec2.auto_scale.group.AutoScalingGroup")
    instanceMock1.name = "testName1"
    instanceMock1.desired_capacity = 64
    # Instance 2
    instanceMock2 = Mock(spec="boto.ec2.auto_scale.group.AutoScalingGroup")
    instanceMock2.name = "testName2"
    instanceMock2.desired_capacity = 65

    getAutoScalingGroupsMock.return_value = [
        instanceMock1,
        instanceMock2,
    ]

    suggestions = asg_utils.getSuggestedInstances(region)
    self.assertIsInstance(suggestions, types.GeneratorType)
    suggestions = list(suggestions)

    self.assertSequenceEqual(suggestions, [
        {"id": "testName2", "name": "testName2", "namespace": "AWS/AutoScaling",
         "region": region},
        {"id": "testName1", "name": "testName1", "namespace": "AWS/AutoScaling",
         "region": region},
    ])
    getAutoScalingGroupsMock.assert_call_once_with(region)
コード例 #2
0
  def testGetSuggestedInstancesNone(self, getAutoScalingGroupsMock):
    getAutoScalingGroupsMock.return_value = []

    suggestions = asg_utils.getSuggestedInstances("dummy-region")
    self.assertIsInstance(suggestions, types.GeneratorType)
    suggestions = list(suggestions)

    self.assertSequenceEqual(suggestions, [])
    getAutoScalingGroupsMock.assert_call_once_with("dummy-region")