Merge "Move keys() methods in each resource class to FakeResource"
This commit is contained in:
commit
3be49a8abe
openstackclient/tests
@ -183,6 +183,9 @@ class FakeResource(object):
|
|||||||
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
||||||
return "<%s %s>" % (self.__class__.__name__, info)
|
return "<%s %s>" % (self.__class__.__name__, info)
|
||||||
|
|
||||||
|
def keys(self):
|
||||||
|
return self._info.keys()
|
||||||
|
|
||||||
|
|
||||||
class FakeResponse(requests.Response):
|
class FakeResponse(requests.Response):
|
||||||
|
|
||||||
|
@ -75,13 +75,11 @@ class FakeAvailabilityZone(object):
|
|||||||
"""Fake one or more network availability zones (AZs)."""
|
"""Fake one or more network availability zones (AZs)."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_availability_zone(attrs={}, methods={}):
|
def create_one_availability_zone(attrs={}):
|
||||||
"""Create a fake AZ.
|
"""Create a fake AZ.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object with name, state, etc.
|
A FakeResource object with name, state, etc.
|
||||||
"""
|
"""
|
||||||
@ -97,18 +95,15 @@ class FakeAvailabilityZone(object):
|
|||||||
|
|
||||||
availability_zone = fakes.FakeResource(
|
availability_zone = fakes.FakeResource(
|
||||||
info=copy.deepcopy(availability_zone),
|
info=copy.deepcopy(availability_zone),
|
||||||
methods=methods,
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
return availability_zone
|
return availability_zone
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_availability_zones(attrs={}, methods={}, count=2):
|
def create_availability_zones(attrs={}, count=2):
|
||||||
"""Create multiple fake AZs.
|
"""Create multiple fake AZs.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of AZs to fake
|
The number of AZs to fake
|
||||||
:return:
|
:return:
|
||||||
@ -117,8 +112,7 @@ class FakeAvailabilityZone(object):
|
|||||||
availability_zones = []
|
availability_zones = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
availability_zone = \
|
availability_zone = \
|
||||||
FakeAvailabilityZone.create_one_availability_zone(
|
FakeAvailabilityZone.create_one_availability_zone(attrs)
|
||||||
attrs, methods)
|
|
||||||
availability_zones.append(availability_zone)
|
availability_zones.append(availability_zone)
|
||||||
|
|
||||||
return availability_zones
|
return availability_zones
|
||||||
@ -128,13 +122,11 @@ class FakeNetwork(object):
|
|||||||
"""Fake one or more networks."""
|
"""Fake one or more networks."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_network(attrs={}, methods={}):
|
def create_one_network(attrs={}):
|
||||||
"""Create a fake network.
|
"""Create a fake network.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, name, admin_state_up,
|
A FakeResource object, with id, name, admin_state_up,
|
||||||
router_external, status, subnets, tenant_id
|
router_external, status, subnets, tenant_id
|
||||||
@ -158,18 +150,7 @@ class FakeNetwork(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
network_attrs.update(attrs)
|
network_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
network_methods = {
|
|
||||||
'keys': ['id', 'name', 'admin_state_up', 'router_external',
|
|
||||||
'status', 'subnets', 'tenant_id', 'availability_zones',
|
|
||||||
'availability_zone_hints', 'is_default'],
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
network_methods.update(methods)
|
|
||||||
|
|
||||||
network = fakes.FakeResource(info=copy.deepcopy(network_attrs),
|
network = fakes.FakeResource(info=copy.deepcopy(network_attrs),
|
||||||
methods=copy.deepcopy(network_methods),
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
|
|
||||||
# Set attributes with special mapping in OpenStack SDK.
|
# Set attributes with special mapping in OpenStack SDK.
|
||||||
@ -178,13 +159,11 @@ class FakeNetwork(object):
|
|||||||
return network
|
return network
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_networks(attrs={}, methods={}, count=2):
|
def create_networks(attrs={}, count=2):
|
||||||
"""Create multiple fake networks.
|
"""Create multiple fake networks.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of networks to fake
|
The number of networks to fake
|
||||||
:return:
|
:return:
|
||||||
@ -192,7 +171,7 @@ class FakeNetwork(object):
|
|||||||
"""
|
"""
|
||||||
networks = []
|
networks = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
networks.append(FakeNetwork.create_one_network(attrs, methods))
|
networks.append(FakeNetwork.create_one_network(attrs))
|
||||||
|
|
||||||
return networks
|
return networks
|
||||||
|
|
||||||
@ -220,7 +199,7 @@ class FakePort(object):
|
|||||||
"""Fake one or more ports."""
|
"""Fake one or more ports."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_port(attrs={}, methods={}):
|
def create_one_port(attrs={}):
|
||||||
"""Create a fake port.
|
"""Create a fake port.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
@ -258,23 +237,7 @@ class FakePort(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
port_attrs.update(attrs)
|
port_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
port_methods = {
|
|
||||||
'keys': ['admin_state_up', 'allowed_address_pairs',
|
|
||||||
'binding:host_id', 'binding:profile',
|
|
||||||
'binding:vif_details', 'binding:vif_type',
|
|
||||||
'binding:vnic_type', 'device_id', 'device_owner',
|
|
||||||
'dns_assignment', 'dns_name', 'extra_dhcp_opts',
|
|
||||||
'fixed_ips', 'id', 'mac_address', 'name',
|
|
||||||
'network_id', 'port_security_enabled',
|
|
||||||
'security_groups', 'status', 'tenant_id'],
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
port_methods.update(methods)
|
|
||||||
|
|
||||||
port = fakes.FakeResource(info=copy.deepcopy(port_attrs),
|
port = fakes.FakeResource(info=copy.deepcopy(port_attrs),
|
||||||
methods=copy.deepcopy(port_methods),
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
|
|
||||||
# Set attributes with special mappings in OpenStack SDK.
|
# Set attributes with special mappings in OpenStack SDK.
|
||||||
@ -288,13 +251,11 @@ class FakePort(object):
|
|||||||
return port
|
return port
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_ports(attrs={}, methods={}, count=2):
|
def create_ports(attrs={}, count=2):
|
||||||
"""Create multiple fake ports.
|
"""Create multiple fake ports.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of ports to fake
|
The number of ports to fake
|
||||||
:return:
|
:return:
|
||||||
@ -302,7 +263,7 @@ class FakePort(object):
|
|||||||
"""
|
"""
|
||||||
ports = []
|
ports = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
ports.append(FakePort.create_one_port(attrs, methods))
|
ports.append(FakePort.create_one_port(attrs))
|
||||||
|
|
||||||
return ports
|
return ports
|
||||||
|
|
||||||
@ -330,13 +291,11 @@ class FakeRouter(object):
|
|||||||
"""Fake one or more routers."""
|
"""Fake one or more routers."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_router(attrs={}, methods={}):
|
def create_one_router(attrs={}):
|
||||||
"""Create a fake router.
|
"""Create a fake router.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, name, admin_state_up,
|
A FakeResource object, with id, name, admin_state_up,
|
||||||
status, tenant_id
|
status, tenant_id
|
||||||
@ -359,17 +318,7 @@ class FakeRouter(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
router_attrs.update(attrs)
|
router_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
router_methods = {
|
|
||||||
'keys': ['id', 'name', 'admin_state_up', 'distributed', 'ha',
|
|
||||||
'tenant_id'],
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
router_methods.update(methods)
|
|
||||||
|
|
||||||
router = fakes.FakeResource(info=copy.deepcopy(router_attrs),
|
router = fakes.FakeResource(info=copy.deepcopy(router_attrs),
|
||||||
methods=copy.deepcopy(router_methods),
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
|
|
||||||
# Set attributes with special mapping in OpenStack SDK.
|
# Set attributes with special mapping in OpenStack SDK.
|
||||||
@ -378,13 +327,11 @@ class FakeRouter(object):
|
|||||||
return router
|
return router
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_routers(attrs={}, methods={}, count=2):
|
def create_routers(attrs={}, count=2):
|
||||||
"""Create multiple fake routers.
|
"""Create multiple fake routers.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of routers to fake
|
The number of routers to fake
|
||||||
:return:
|
:return:
|
||||||
@ -392,7 +339,7 @@ class FakeRouter(object):
|
|||||||
"""
|
"""
|
||||||
routers = []
|
routers = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
routers.append(FakeRouter.create_one_router(attrs, methods))
|
routers.append(FakeRouter.create_one_router(attrs))
|
||||||
|
|
||||||
return routers
|
return routers
|
||||||
|
|
||||||
@ -420,20 +367,16 @@ class FakeSecurityGroup(object):
|
|||||||
"""Fake one or more security groups."""
|
"""Fake one or more security groups."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_security_group(attrs=None, methods=None):
|
def create_one_security_group(attrs=None):
|
||||||
"""Create a fake security group.
|
"""Create a fake security group.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, name, etc.
|
A FakeResource object, with id, name, etc.
|
||||||
"""
|
"""
|
||||||
if attrs is None:
|
if attrs is None:
|
||||||
attrs = {}
|
attrs = {}
|
||||||
if methods is None:
|
|
||||||
methods = {}
|
|
||||||
|
|
||||||
# Set default attributes.
|
# Set default attributes.
|
||||||
security_group_attrs = {
|
security_group_attrs = {
|
||||||
@ -447,18 +390,8 @@ class FakeSecurityGroup(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
security_group_attrs.update(attrs)
|
security_group_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
security_group_methods = {
|
|
||||||
'keys': ['id', 'name', 'description', 'tenant_id',
|
|
||||||
'security_group_rules'],
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
security_group_methods.update(methods)
|
|
||||||
|
|
||||||
security_group = fakes.FakeResource(
|
security_group = fakes.FakeResource(
|
||||||
info=copy.deepcopy(security_group_attrs),
|
info=copy.deepcopy(security_group_attrs),
|
||||||
methods=copy.deepcopy(security_group_methods),
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
|
|
||||||
# Set attributes with special mapping in OpenStack SDK.
|
# Set attributes with special mapping in OpenStack SDK.
|
||||||
@ -467,13 +400,11 @@ class FakeSecurityGroup(object):
|
|||||||
return security_group
|
return security_group
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_security_groups(attrs=None, methods=None, count=2):
|
def create_security_groups(attrs=None, count=2):
|
||||||
"""Create multiple fake security groups.
|
"""Create multiple fake security groups.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of security groups to fake
|
The number of security groups to fake
|
||||||
:return:
|
:return:
|
||||||
@ -482,7 +413,7 @@ class FakeSecurityGroup(object):
|
|||||||
security_groups = []
|
security_groups = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
security_groups.append(
|
security_groups.append(
|
||||||
FakeSecurityGroup.create_one_security_group(attrs, methods))
|
FakeSecurityGroup.create_one_security_group(attrs))
|
||||||
|
|
||||||
return security_groups
|
return security_groups
|
||||||
|
|
||||||
@ -491,20 +422,16 @@ class FakeSecurityGroupRule(object):
|
|||||||
"""Fake one or more security group rules."""
|
"""Fake one or more security group rules."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_security_group_rule(attrs=None, methods=None):
|
def create_one_security_group_rule(attrs=None):
|
||||||
"""Create a fake security group rule.
|
"""Create a fake security group rule.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, etc.
|
A FakeResource object, with id, etc.
|
||||||
"""
|
"""
|
||||||
if attrs is None:
|
if attrs is None:
|
||||||
attrs = {}
|
attrs = {}
|
||||||
if methods is None:
|
|
||||||
methods = {}
|
|
||||||
|
|
||||||
# Set default attributes.
|
# Set default attributes.
|
||||||
security_group_rule_attrs = {
|
security_group_rule_attrs = {
|
||||||
@ -523,19 +450,8 @@ class FakeSecurityGroupRule(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
security_group_rule_attrs.update(attrs)
|
security_group_rule_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
security_group_rule_methods = {
|
|
||||||
'keys': ['direction', 'ethertype', 'id', 'port_range_max',
|
|
||||||
'port_range_min', 'protocol', 'remote_group_id',
|
|
||||||
'remote_ip_prefix', 'security_group_id', 'tenant_id'],
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
security_group_rule_methods.update(methods)
|
|
||||||
|
|
||||||
security_group_rule = fakes.FakeResource(
|
security_group_rule = fakes.FakeResource(
|
||||||
info=copy.deepcopy(security_group_rule_attrs),
|
info=copy.deepcopy(security_group_rule_attrs),
|
||||||
methods=copy.deepcopy(security_group_rule_methods),
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
|
|
||||||
# Set attributes with special mapping in OpenStack SDK.
|
# Set attributes with special mapping in OpenStack SDK.
|
||||||
@ -544,13 +460,11 @@ class FakeSecurityGroupRule(object):
|
|||||||
return security_group_rule
|
return security_group_rule
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_security_group_rules(attrs=None, methods=None, count=2):
|
def create_security_group_rules(attrs=None, count=2):
|
||||||
"""Create multiple fake security group rules.
|
"""Create multiple fake security group rules.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of security group rules to fake
|
The number of security group rules to fake
|
||||||
:return:
|
:return:
|
||||||
@ -559,8 +473,7 @@ class FakeSecurityGroupRule(object):
|
|||||||
security_group_rules = []
|
security_group_rules = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
security_group_rules.append(
|
security_group_rules.append(
|
||||||
FakeSecurityGroupRule.create_one_security_group_rule(
|
FakeSecurityGroupRule.create_one_security_group_rule(attrs))
|
||||||
attrs, methods))
|
|
||||||
|
|
||||||
return security_group_rules
|
return security_group_rules
|
||||||
|
|
||||||
@ -569,13 +482,11 @@ class FakeSubnet(object):
|
|||||||
"""Fake one or more subnets."""
|
"""Fake one or more subnets."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_subnet(attrs={}, methods={}):
|
def create_one_subnet(attrs={}):
|
||||||
"""Create a fake subnet.
|
"""Create a fake subnet.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object faking the subnet
|
A FakeResource object faking the subnet
|
||||||
"""
|
"""
|
||||||
@ -601,19 +512,7 @@ class FakeSubnet(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
subnet_attrs.update(attrs)
|
subnet_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
subnet_methods = {
|
|
||||||
'keys': ['id', 'name', 'network_id', 'cidr', 'enable_dhcp',
|
|
||||||
'allocation_pools', 'dns_nameservers', 'gateway_ip',
|
|
||||||
'host_routes', 'ip_version', 'tenant_id',
|
|
||||||
'ipv6_address_mode', 'ipv6_ra_mode', 'subnetpool_id']
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
subnet_methods.update(methods)
|
|
||||||
|
|
||||||
subnet = fakes.FakeResource(info=copy.deepcopy(subnet_attrs),
|
subnet = fakes.FakeResource(info=copy.deepcopy(subnet_attrs),
|
||||||
methods=copy.deepcopy(subnet_methods),
|
|
||||||
loaded=True)
|
loaded=True)
|
||||||
# Set attributes with special mappings in OpenStack SDK.
|
# Set attributes with special mappings in OpenStack SDK.
|
||||||
subnet.project_id = subnet_attrs['tenant_id']
|
subnet.project_id = subnet_attrs['tenant_id']
|
||||||
@ -621,13 +520,11 @@ class FakeSubnet(object):
|
|||||||
return subnet
|
return subnet
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_subnets(attrs={}, methods={}, count=2):
|
def create_subnets(attrs={}, count=2):
|
||||||
"""Create multiple fake subnets.
|
"""Create multiple fake subnets.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of subnets to fake
|
The number of subnets to fake
|
||||||
:return:
|
:return:
|
||||||
@ -635,7 +532,7 @@ class FakeSubnet(object):
|
|||||||
"""
|
"""
|
||||||
subnets = []
|
subnets = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
subnets.append(FakeSubnet.create_one_subnet(attrs, methods))
|
subnets.append(FakeSubnet.create_one_subnet(attrs))
|
||||||
|
|
||||||
return subnets
|
return subnets
|
||||||
|
|
||||||
@ -644,13 +541,11 @@ class FakeFloatingIP(object):
|
|||||||
"""Fake one or more floating ip."""
|
"""Fake one or more floating ip."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_floating_ip(attrs={}, methods={}):
|
def create_one_floating_ip(attrs={}):
|
||||||
"""Create a fake floating ip.
|
"""Create a fake floating ip.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object, with id, ip, and so on
|
A FakeResource object, with id, ip, and so on
|
||||||
"""
|
"""
|
||||||
@ -671,19 +566,8 @@ class FakeFloatingIP(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
floating_ip_attrs.update(attrs)
|
floating_ip_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
floating_ip_methods = {
|
|
||||||
'keys': ['id', 'floating_ip_address', 'fixed_ip_address',
|
|
||||||
'dns_domain', 'dns_name', 'status', 'router_id',
|
|
||||||
'floating_network_id', 'port_id', 'tenant_id']
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
floating_ip_methods.update(methods)
|
|
||||||
|
|
||||||
floating_ip = fakes.FakeResource(
|
floating_ip = fakes.FakeResource(
|
||||||
info=copy.deepcopy(floating_ip_attrs),
|
info=copy.deepcopy(floating_ip_attrs),
|
||||||
methods=copy.deepcopy(floating_ip_methods),
|
|
||||||
loaded=True
|
loaded=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -693,13 +577,11 @@ class FakeFloatingIP(object):
|
|||||||
return floating_ip
|
return floating_ip
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_floating_ips(attrs={}, methods={}, count=2):
|
def create_floating_ips(attrs={}, count=2):
|
||||||
"""Create multiple fake floating ips.
|
"""Create multiple fake floating ips.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of floating ips to fake
|
The number of floating ips to fake
|
||||||
:return:
|
:return:
|
||||||
@ -707,10 +589,7 @@ class FakeFloatingIP(object):
|
|||||||
"""
|
"""
|
||||||
floating_ips = []
|
floating_ips = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
floating_ips.append(FakeFloatingIP.create_one_floating_ip(
|
floating_ips.append(FakeFloatingIP.create_one_floating_ip(attrs))
|
||||||
attrs,
|
|
||||||
methods
|
|
||||||
))
|
|
||||||
return floating_ips
|
return floating_ips
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -737,13 +616,11 @@ class FakeSubnetPool(object):
|
|||||||
"""Fake one or more subnet pools."""
|
"""Fake one or more subnet pools."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_one_subnet_pool(attrs={}, methods={}):
|
def create_one_subnet_pool(attrs={}):
|
||||||
"""Create a fake subnet pool.
|
"""Create a fake subnet pool.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
:return:
|
||||||
A FakeResource object faking the subnet pool
|
A FakeResource object faking the subnet pool
|
||||||
"""
|
"""
|
||||||
@ -766,20 +643,8 @@ class FakeSubnetPool(object):
|
|||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
subnet_pool_attrs.update(attrs)
|
subnet_pool_attrs.update(attrs)
|
||||||
|
|
||||||
# Set default methods.
|
|
||||||
subnet_pool_methods = {
|
|
||||||
'keys': ['id', 'name', 'prefixes', 'default_prefixlen',
|
|
||||||
'address_scope_id', 'tenant_id', 'is_default',
|
|
||||||
'shared', 'max_prefixlen', 'min_prefixlen',
|
|
||||||
'default_quota', 'ip_version']
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default methods.
|
|
||||||
subnet_pool_methods.update(methods)
|
|
||||||
|
|
||||||
subnet_pool = fakes.FakeResource(
|
subnet_pool = fakes.FakeResource(
|
||||||
info=copy.deepcopy(subnet_pool_attrs),
|
info=copy.deepcopy(subnet_pool_attrs),
|
||||||
methods=copy.deepcopy(subnet_pool_methods),
|
|
||||||
loaded=True
|
loaded=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -789,13 +654,11 @@ class FakeSubnetPool(object):
|
|||||||
return subnet_pool
|
return subnet_pool
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_subnet_pools(attrs={}, methods={}, count=2):
|
def create_subnet_pools(attrs={}, count=2):
|
||||||
"""Create multiple fake subnet pools.
|
"""Create multiple fake subnet pools.
|
||||||
|
|
||||||
:param Dictionary attrs:
|
:param Dictionary attrs:
|
||||||
A dictionary with all attributes
|
A dictionary with all attributes
|
||||||
:param Dictionary methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:param int count:
|
:param int count:
|
||||||
The number of subnet pools to fake
|
The number of subnet pools to fake
|
||||||
:return:
|
:return:
|
||||||
@ -804,7 +667,7 @@ class FakeSubnetPool(object):
|
|||||||
subnet_pools = []
|
subnet_pools = []
|
||||||
for i in range(0, count):
|
for i in range(0, count):
|
||||||
subnet_pools.append(
|
subnet_pools.append(
|
||||||
FakeSubnetPool.create_one_subnet_pool(attrs, methods)
|
FakeSubnetPool.create_one_subnet_pool(attrs)
|
||||||
)
|
)
|
||||||
|
|
||||||
return subnet_pools
|
return subnet_pools
|
||||||
|
@ -54,7 +54,9 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
|||||||
'is_default',
|
'is_default',
|
||||||
'name',
|
'name',
|
||||||
'project_id',
|
'project_id',
|
||||||
|
'provider_network_type',
|
||||||
'router_external',
|
'router_external',
|
||||||
|
'shared',
|
||||||
'status',
|
'status',
|
||||||
'subnets',
|
'subnets',
|
||||||
)
|
)
|
||||||
@ -67,7 +69,9 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
|||||||
_network.is_default,
|
_network.is_default,
|
||||||
_network.name,
|
_network.name,
|
||||||
_network.project_id,
|
_network.project_id,
|
||||||
|
_network.provider_network_type,
|
||||||
network._format_router_external(_network.router_external),
|
network._format_router_external(_network.router_external),
|
||||||
|
_network.shared,
|
||||||
_network.status,
|
_network.status,
|
||||||
utils.format_list(_network.subnets),
|
utils.format_list(_network.subnets),
|
||||||
)
|
)
|
||||||
@ -219,7 +223,9 @@ class TestCreateNetworkIdentityV2(TestNetwork):
|
|||||||
'is_default',
|
'is_default',
|
||||||
'name',
|
'name',
|
||||||
'project_id',
|
'project_id',
|
||||||
|
'provider_network_type',
|
||||||
'router_external',
|
'router_external',
|
||||||
|
'shared',
|
||||||
'status',
|
'status',
|
||||||
'subnets',
|
'subnets',
|
||||||
)
|
)
|
||||||
@ -232,7 +238,9 @@ class TestCreateNetworkIdentityV2(TestNetwork):
|
|||||||
_network.is_default,
|
_network.is_default,
|
||||||
_network.name,
|
_network.name,
|
||||||
_network.project_id,
|
_network.project_id,
|
||||||
|
_network.provider_network_type,
|
||||||
network._format_router_external(_network.router_external),
|
network._format_router_external(_network.router_external),
|
||||||
|
_network.shared,
|
||||||
_network.status,
|
_network.status,
|
||||||
utils.format_list(_network.subnets),
|
utils.format_list(_network.subnets),
|
||||||
)
|
)
|
||||||
@ -539,7 +547,9 @@ class TestShowNetwork(TestNetwork):
|
|||||||
'is_default',
|
'is_default',
|
||||||
'name',
|
'name',
|
||||||
'project_id',
|
'project_id',
|
||||||
|
'provider_network_type',
|
||||||
'router_external',
|
'router_external',
|
||||||
|
'shared',
|
||||||
'status',
|
'status',
|
||||||
'subnets',
|
'subnets',
|
||||||
)
|
)
|
||||||
@ -552,7 +562,9 @@ class TestShowNetwork(TestNetwork):
|
|||||||
_network.is_default,
|
_network.is_default,
|
||||||
_network.name,
|
_network.name,
|
||||||
_network.project_id,
|
_network.project_id,
|
||||||
|
_network.provider_network_type,
|
||||||
network._format_router_external(_network.router_external),
|
network._format_router_external(_network.router_external),
|
||||||
|
_network.shared,
|
||||||
_network.status,
|
_network.status,
|
||||||
utils.format_list(_network.subnets),
|
utils.format_list(_network.subnets),
|
||||||
)
|
)
|
||||||
|
@ -117,19 +117,29 @@ class TestCreateRouter(TestRouter):
|
|||||||
|
|
||||||
columns = (
|
columns = (
|
||||||
'admin_state_up',
|
'admin_state_up',
|
||||||
|
'availability_zone_hints',
|
||||||
|
'availability_zones',
|
||||||
'distributed',
|
'distributed',
|
||||||
|
'external_gateway_info',
|
||||||
'ha',
|
'ha',
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'project_id',
|
'project_id',
|
||||||
|
'routes',
|
||||||
|
'status',
|
||||||
)
|
)
|
||||||
data = (
|
data = (
|
||||||
router._format_admin_state(new_router.admin_state_up),
|
router._format_admin_state(new_router.admin_state_up),
|
||||||
|
osc_utils.format_list(new_router.availability_zone_hints),
|
||||||
|
osc_utils.format_list(new_router.availability_zones),
|
||||||
new_router.distributed,
|
new_router.distributed,
|
||||||
|
router._format_external_gateway_info(new_router.external_gateway_info),
|
||||||
new_router.ha,
|
new_router.ha,
|
||||||
new_router.id,
|
new_router.id,
|
||||||
new_router.name,
|
new_router.name,
|
||||||
new_router.tenant_id,
|
new_router.tenant_id,
|
||||||
|
new_router.routes,
|
||||||
|
new_router.status,
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -541,20 +551,29 @@ class TestShowRouter(TestRouter):
|
|||||||
|
|
||||||
columns = (
|
columns = (
|
||||||
'admin_state_up',
|
'admin_state_up',
|
||||||
|
'availability_zone_hints',
|
||||||
|
'availability_zones',
|
||||||
'distributed',
|
'distributed',
|
||||||
|
'external_gateway_info',
|
||||||
'ha',
|
'ha',
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'project_id',
|
'project_id',
|
||||||
|
'routes',
|
||||||
|
'status',
|
||||||
)
|
)
|
||||||
|
|
||||||
data = (
|
data = (
|
||||||
router._format_admin_state(_router.admin_state_up),
|
router._format_admin_state(_router.admin_state_up),
|
||||||
|
osc_utils.format_list(_router.availability_zone_hints),
|
||||||
|
osc_utils.format_list(_router.availability_zones),
|
||||||
_router.distributed,
|
_router.distributed,
|
||||||
|
router._format_external_gateway_info(_router.external_gateway_info),
|
||||||
_router.ha,
|
_router.ha,
|
||||||
_router.id,
|
_router.id,
|
||||||
_router.name,
|
_router.name,
|
||||||
_router.project_id,
|
_router.tenant_id,
|
||||||
|
_router.routes,
|
||||||
|
_router.status,
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user