@@ -611,6 +611,25 @@ def create_security_groups(attrs=None, count=2):
611611
612612 return security_groups
613613
614+ @staticmethod
615+ def get_security_groups (security_groups = None , count = 2 ):
616+ """Get an iterable MagicMock object with a list of faked security groups.
617+
618+ If security groups list is provided, then initialize the Mock object
619+ with the list. Otherwise create one.
620+
621+ :param List security groups:
622+ A list of FakeResource objects faking security groups
623+ :param int count:
624+ The number of security groups to fake
625+ :return:
626+ An iterable Mock object with side_effect set to a list of faked
627+ security groups
628+ """
629+ if security_groups is None :
630+ security_groups = FakeSecurityGroup .create_security_groups (count )
631+ return mock .MagicMock (side_effect = security_groups )
632+
614633
615634class FakeSecurityGroupRule (object ):
616635 """Fake one or more security group rules."""
@@ -670,6 +689,26 @@ def create_security_group_rules(attrs=None, count=2):
670689
671690 return security_group_rules
672691
692+ @staticmethod
693+ def get_security_group_rules (security_group_rules = None , count = 2 ):
694+ """Get an iterable MagicMock object with a list of faked security group rules.
695+
696+ If security group rules list is provided, then initialize the Mock
697+ object with the list. Otherwise create one.
698+
699+ :param List security group rules:
700+ A list of FakeResource objects faking security group rules
701+ :param int count:
702+ The number of security group rules to fake
703+ :return:
704+ An iterable Mock object with side_effect set to a list of faked
705+ security group rules
706+ """
707+ if security_group_rules is None :
708+ security_group_rules = (
709+ FakeSecurityGroupRule .create_security_group_rules (count ))
710+ return mock .MagicMock (side_effect = security_group_rules )
711+
673712
674713class FakeSubnet (object ):
675714 """Fake one or more subnets."""
0 commit comments