Esempio n. 1
0
  def testGetSuggestedInstancesTwoDifferentSize(self, getELBInstancesMock):
    region = "us-west-2"
    # Instance 1
    instanceMock1 = Mock(spec="boto.ec2.elb.load_balancer.LoadBalancer")
    instanceMock1.name = "testName1"
    instanceMock1.instances = ["a", "b"]
    # Instance 2
    instanceMock2 = Mock(spec="boto.ec2.elb.load_balancer.LoadBalancer")
    instanceMock2.name = "testName2"
    instanceMock2.instances = ["c", "d", "e"]

    getELBInstancesMock.return_value = [
        instanceMock1,
        instanceMock2,
    ]

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

    self.assertSequenceEqual(suggestions, [
        {"id": "testName2", "name": "testName2", "namespace": "AWS/ELB",
         "region": region},
        {"id": "testName1", "name": "testName1", "namespace": "AWS/ELB",
         "region": region},
    ])
    getELBInstancesMock.assert_call_once_with(region)
Esempio n. 2
0
    def testGetSuggestedInstancesTwoDifferentSize(self, getELBInstancesMock):
        region = "us-west-2"
        # Instance 1
        instanceMock1 = Mock(spec="boto.ec2.elb.load_balancer.LoadBalancer")
        instanceMock1.name = "testName1"
        instanceMock1.instances = ["a", "b"]
        # Instance 2
        instanceMock2 = Mock(spec="boto.ec2.elb.load_balancer.LoadBalancer")
        instanceMock2.name = "testName2"
        instanceMock2.instances = ["c", "d", "e"]

        getELBInstancesMock.return_value = [instanceMock1, instanceMock2]

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

        self.assertSequenceEqual(
            suggestions,
            [
                {"id": "testName2", "name": "testName2", "namespace": "AWS/ELB", "region": region},
                {"id": "testName1", "name": "testName1", "namespace": "AWS/ELB", "region": region},
            ],
        )
        getELBInstancesMock.assert_call_once_with(region)
Esempio n. 3
0
  def testGetSuggestedInstancesNone(self, getELBInstancesMock):
    getELBInstancesMock.return_value = []

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

    self.assertSequenceEqual(suggestions, [])
    getELBInstancesMock.assert_call_once_with("dummy-region")
Esempio n. 4
0
    def testGetSuggestedInstancesNone(self, getELBInstancesMock):
        getELBInstancesMock.return_value = []

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

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