def testGetSuggestedInstancesTwoDifferentSize(self, getRDSInstancesMock): region = "us-west-2" # Instance 1 instanceMock1 = Mock(spec="boto.rds.dbinstance.DBInstance") instanceMock1.status = "available" instanceMock1.allocated_storage = 64.0 instanceMock1.id = "testId1" # Instance 2 instanceMock2 = Mock(spec="boto.rds.dbinstance.DBInstance") instanceMock2.status = "available" instanceMock2.allocated_storage = 65.0 instanceMock2.id = "testId2" getRDSInstancesMock.return_value = [ instanceMock1, instanceMock2, ] suggestions = rds_utils.getSuggestedInstances(region) self.assertIsInstance(suggestions, types.GeneratorType) suggestions = list(suggestions) self.assertSequenceEqual(suggestions, [ {"id": "testId2", "name": "testId2", "namespace": "AWS/RDS", "region": region}, {"id": "testId1", "name": "testId1", "namespace": "AWS/RDS", "region": region}, ]) getRDSInstancesMock.assert_call_once_with(region)
def testGetSuggestedInstancesNone(self, getRDSInstancesMock): getRDSInstancesMock.return_value = [] suggestions = rds_utils.getSuggestedInstances("dummy-region") self.assertIsInstance(suggestions, types.GeneratorType) suggestions = list(suggestions) self.assertSequenceEqual(suggestions, []) getRDSInstancesMock.assert_call_once_with("dummy-region")
def testGetSuggestedInstancesNoAvailable(self, getRDSInstancesMock): instanceMock1 = Mock(spec="boto.rds.dbinstance.DBInstance") instanceMock1.status = "not-available" getRDSInstancesMock.return_value = [ instanceMock1, ] suggestions = rds_utils.getSuggestedInstances("dummy-region") self.assertIsInstance(suggestions, types.GeneratorType) suggestions = list(suggestions) self.assertSequenceEqual(suggestions, []) getRDSInstancesMock.assert_call_once_with("dummy-region")