def test_uses_paginator_for_describe_auto_scaling_groups(self): autoscaling = mock.Mock() paginator = autoscaling.get_paginator.return_value paginator.paginate.return_value = iter([]) asgs = chaos.get_all_asgs(autoscaling) list(asgs) # force evaluation of the generator autoscaling.get_paginator.assert_called_once_with( "describe_auto_scaling_groups") paginator.paginate.assert_called_once_with()
def test_uses_paginator_for_describe_auto_scaling_groups(self): autoscaling = mock.Mock() paginator = autoscaling.get_paginator.return_value paginator.paginate.return_value = iter([]) asgs = chaos.get_all_asgs(autoscaling) list(asgs) # force evaluation of the generator autoscaling.get_paginator.assert_called_once_with( "describe_auto_scaling_groups" ) paginator.paginate.assert_called_once_with()
def test_ignores_responses_with_missing_AutoScalingGroups_key(self): autoscaling = mock.Mock() paginator = autoscaling.get_paginator.return_value paginator.paginate.return_value = iter([{ "AutoScalingGroups": [mock.sentinel.one] }, {}, { "AutoScalingGroups": [mock.sentinel.two] }]) asgs = chaos.get_all_asgs(autoscaling) self.assertEqual(set(asgs), set([mock.sentinel.one, mock.sentinel.two]))
def test_ignores_responses_with_missing_AutoScalingGroups_key(self): autoscaling = mock.Mock() paginator = autoscaling.get_paginator.return_value paginator.paginate.return_value = iter([ {"AutoScalingGroups": [mock.sentinel.one]}, {}, {"AutoScalingGroups": [mock.sentinel.two]} ]) asgs = chaos.get_all_asgs(autoscaling) self.assertEqual(set(asgs), set([ mock.sentinel.one, mock.sentinel.two ]))
def test_yields_asgs_from_each_response(self): autoscaling = mock.Mock() paginator = autoscaling.get_paginator.return_value paginator.paginate.return_value = iter([ {"AutoScalingGroups": [mock.sentinel.one, mock.sentinel.two]}, {"AutoScalingGroups": [mock.sentinel.three]}, {"AutoScalingGroups": [mock.sentinel.four, mock.sentinel.five]} ]) asgs = chaos.get_all_asgs(autoscaling) self.assertEqual(set(asgs), set([ mock.sentinel.one, mock.sentinel.two, mock.sentinel.three, mock.sentinel.four, mock.sentinel.five ]))
def test_yields_asgs_from_each_response(self): autoscaling = mock.Mock() paginator = autoscaling.get_paginator.return_value paginator.paginate.return_value = iter([{ "AutoScalingGroups": [mock.sentinel.one, mock.sentinel.two] }, { "AutoScalingGroups": [mock.sentinel.three] }, { "AutoScalingGroups": [mock.sentinel.four, mock.sentinel.five] }]) asgs = chaos.get_all_asgs(autoscaling) self.assertEqual( set(asgs), set([ mock.sentinel.one, mock.sentinel.two, mock.sentinel.three, mock.sentinel.four, mock.sentinel.five ]))