@@ -631,3 +631,64 @@ def get_floating_ips(floating_ips=None, count=2):
631631 if floating_ips is None :
632632 floating_ips = FakeFloatingIP .create_floating_ips (count )
633633 return mock .MagicMock (side_effect = floating_ips )
634+
635+
636+ class FakeSubnetPool (object ):
637+ """Fake one or more subnet pools."""
638+
639+ @staticmethod
640+ def create_one_subnet_pool (attrs = {}, methods = {}):
641+ """Create a fake subnet pool.
642+
643+ :param Dictionary attrs:
644+ A dictionary with all attributes
645+ :param Dictionary methods:
646+ A dictionary with all methods
647+ :return:
648+ A FakeResource object faking the subnet pool
649+ """
650+ # Set default attributes.
651+ subnet_pool_attrs = {
652+ 'id' : 'subnet-pool-id-' + uuid .uuid4 ().hex ,
653+ 'name' : 'subnet-pool-name-' + uuid .uuid4 ().hex ,
654+ }
655+
656+ # Overwrite default attributes.
657+ subnet_pool_attrs .update (attrs )
658+
659+ # Set default methods.
660+ subnet_pool_methods = {
661+ 'keys' : ['id' , 'name' ]
662+ }
663+
664+ # Overwrite default methods.
665+ subnet_pool_methods .update (methods )
666+
667+ subnet_pool = fakes .FakeResource (
668+ info = copy .deepcopy (subnet_pool_attrs ),
669+ methods = copy .deepcopy (subnet_pool_methods ),
670+ loaded = True
671+ )
672+
673+ return subnet_pool
674+
675+ @staticmethod
676+ def create_subnet_pools (attrs = {}, methods = {}, count = 2 ):
677+ """Create multiple fake subnet pools.
678+
679+ :param Dictionary attrs:
680+ A dictionary with all attributes
681+ :param Dictionary methods:
682+ A dictionary with all methods
683+ :param int count:
684+ The number of subnet pools to fake
685+ :return:
686+ A list of FakeResource objects faking the subnet pools
687+ """
688+ subnet_pools = []
689+ for i in range (0 , count ):
690+ subnet_pools .append (
691+ FakeSubnetPool .create_one_subnet_pool (attrs , methods )
692+ )
693+
694+ return subnet_pools
0 commit comments