Fix camelcase_to_underscore. Closes #767.
This commit is contained in:
parent
446843e756
commit
25e2af0320
@ -12,10 +12,18 @@ def camelcase_to_underscores(argument):
|
||||
python underscore variable like the_new_attribute'''
|
||||
result = ''
|
||||
prev_char_title = True
|
||||
for char in argument:
|
||||
if char.istitle() and not prev_char_title:
|
||||
# Only add underscore if char is capital, not first letter, and prev
|
||||
# char wasn't capital
|
||||
for index, char in enumerate(argument):
|
||||
try:
|
||||
next_char_title = argument[index + 1].istitle()
|
||||
except IndexError:
|
||||
next_char_title = True
|
||||
|
||||
upper_to_lower = char.istitle() and not next_char_title
|
||||
lower_to_upper = char.istitle() and not prev_char_title
|
||||
|
||||
if index and (upper_to_lower or lower_to_upper):
|
||||
# Only add underscore if char is capital, not first letter, and next
|
||||
# char is not capital
|
||||
result += "_"
|
||||
prev_char_title = char.istitle()
|
||||
if not char.isspace(): # Only add non-whitespace
|
||||
|
@ -85,7 +85,7 @@ class FakeLoadBalancer(BaseModel):
|
||||
instance_port=(
|
||||
port.get('instance_port') or port['InstancePort']),
|
||||
ssl_certificate_id=port.get(
|
||||
'sslcertificate_id', port.get('SSLCertificateId')),
|
||||
'ssl_certificate_id', port.get('SSLCertificateId')),
|
||||
)
|
||||
self.listeners.append(listener)
|
||||
|
||||
|
@ -94,7 +94,7 @@ class ELBResponse(BaseResponse):
|
||||
load_balancer_name, instance_ids)
|
||||
return template.render(load_balancer=load_balancer)
|
||||
|
||||
def set_load_balancer_listener_sslcertificate(self):
|
||||
def set_load_balancer_listener_ssl_certificate(self):
|
||||
load_balancer_name = self._get_param('LoadBalancerName')
|
||||
ssl_certificate_id = self.querystring['SSLCertificateId'][0]
|
||||
lb_port = self.querystring['LoadBalancerPort'][0]
|
||||
@ -188,7 +188,7 @@ class ELBResponse(BaseResponse):
|
||||
template = self.response_template(CREATE_LOAD_BALANCER_POLICY_TEMPLATE)
|
||||
return template.render()
|
||||
|
||||
def create_lbcookie_stickiness_policy(self):
|
||||
def create_lb_cookie_stickiness_policy(self):
|
||||
load_balancer_name = self._get_param('LoadBalancerName')
|
||||
|
||||
policy = AppCookieStickinessPolicy()
|
||||
|
@ -72,27 +72,27 @@ class RDSResponse(BaseResponse):
|
||||
count += 1
|
||||
return unpacked_list
|
||||
|
||||
def create_dbinstance(self):
|
||||
def create_db_instance(self):
|
||||
db_kwargs = self._get_db_kwargs()
|
||||
|
||||
database = self.backend.create_database(db_kwargs)
|
||||
template = self.response_template(CREATE_DATABASE_TEMPLATE)
|
||||
return template.render(database=database)
|
||||
|
||||
def create_dbinstance_read_replica(self):
|
||||
def create_db_instance_read_replica(self):
|
||||
db_kwargs = self._get_db_replica_kwargs()
|
||||
|
||||
database = self.backend.create_database_replica(db_kwargs)
|
||||
template = self.response_template(CREATE_DATABASE_REPLICA_TEMPLATE)
|
||||
return template.render(database=database)
|
||||
|
||||
def describe_dbinstances(self):
|
||||
def describe_db_instances(self):
|
||||
db_instance_identifier = self._get_param('DBInstanceIdentifier')
|
||||
databases = self.backend.describe_databases(db_instance_identifier)
|
||||
template = self.response_template(DESCRIBE_DATABASES_TEMPLATE)
|
||||
return template.render(databases=databases)
|
||||
|
||||
def modify_dbinstance(self):
|
||||
def modify_db_instance(self):
|
||||
db_instance_identifier = self._get_param('DBInstanceIdentifier')
|
||||
db_kwargs = self._get_db_kwargs()
|
||||
database = self.backend.modify_database(
|
||||
@ -100,13 +100,13 @@ class RDSResponse(BaseResponse):
|
||||
template = self.response_template(MODIFY_DATABASE_TEMPLATE)
|
||||
return template.render(database=database)
|
||||
|
||||
def delete_dbinstance(self):
|
||||
def delete_db_instance(self):
|
||||
db_instance_identifier = self._get_param('DBInstanceIdentifier')
|
||||
database = self.backend.delete_database(db_instance_identifier)
|
||||
template = self.response_template(DELETE_DATABASE_TEMPLATE)
|
||||
return template.render(database=database)
|
||||
|
||||
def create_dbsecurity_group(self):
|
||||
def create_db_security_group(self):
|
||||
group_name = self._get_param('DBSecurityGroupName')
|
||||
description = self._get_param('DBSecurityGroupDescription')
|
||||
tags = self.unpack_complex_list_params('Tags.Tag', ('Key', 'Value'))
|
||||
@ -115,21 +115,21 @@ class RDSResponse(BaseResponse):
|
||||
template = self.response_template(CREATE_SECURITY_GROUP_TEMPLATE)
|
||||
return template.render(security_group=security_group)
|
||||
|
||||
def describe_dbsecurity_groups(self):
|
||||
def describe_db_security_groups(self):
|
||||
security_group_name = self._get_param('DBSecurityGroupName')
|
||||
security_groups = self.backend.describe_security_groups(
|
||||
security_group_name)
|
||||
template = self.response_template(DESCRIBE_SECURITY_GROUPS_TEMPLATE)
|
||||
return template.render(security_groups=security_groups)
|
||||
|
||||
def delete_dbsecurity_group(self):
|
||||
def delete_db_security_group(self):
|
||||
security_group_name = self._get_param('DBSecurityGroupName')
|
||||
security_group = self.backend.delete_security_group(
|
||||
security_group_name)
|
||||
template = self.response_template(DELETE_SECURITY_GROUP_TEMPLATE)
|
||||
return template.render(security_group=security_group)
|
||||
|
||||
def authorize_dbsecurity_group_ingress(self):
|
||||
def authorize_db_security_group_ingress(self):
|
||||
security_group_name = self._get_param('DBSecurityGroupName')
|
||||
cidr_ip = self._get_param('CIDRIP')
|
||||
security_group = self.backend.authorize_security_group(
|
||||
@ -137,7 +137,7 @@ class RDSResponse(BaseResponse):
|
||||
template = self.response_template(AUTHORIZE_SECURITY_GROUP_TEMPLATE)
|
||||
return template.render(security_group=security_group)
|
||||
|
||||
def create_dbsubnet_group(self):
|
||||
def create_db_subnet_group(self):
|
||||
subnet_name = self._get_param('DBSubnetGroupName')
|
||||
description = self._get_param('DBSubnetGroupDescription')
|
||||
subnet_ids = self._get_multi_param('SubnetIds.member')
|
||||
@ -149,13 +149,13 @@ class RDSResponse(BaseResponse):
|
||||
template = self.response_template(CREATE_SUBNET_GROUP_TEMPLATE)
|
||||
return template.render(subnet_group=subnet_group)
|
||||
|
||||
def describe_dbsubnet_groups(self):
|
||||
def describe_db_subnet_groups(self):
|
||||
subnet_name = self._get_param('DBSubnetGroupName')
|
||||
subnet_groups = self.backend.describe_subnet_groups(subnet_name)
|
||||
template = self.response_template(DESCRIBE_SUBNET_GROUPS_TEMPLATE)
|
||||
return template.render(subnet_groups=subnet_groups)
|
||||
|
||||
def delete_dbsubnet_group(self):
|
||||
def delete_db_subnet_group(self):
|
||||
subnet_name = self._get_param('DBSubnetGroupName')
|
||||
subnet_group = self.backend.delete_subnet_group(subnet_name)
|
||||
template = self.response_template(DELETE_SUBNET_GROUP_TEMPLATE)
|
||||
|
@ -99,18 +99,12 @@ class RDS2Response(BaseResponse):
|
||||
count += 1
|
||||
return unpacked_list
|
||||
|
||||
def create_dbinstance(self):
|
||||
return self.create_db_instance()
|
||||
|
||||
def create_db_instance(self):
|
||||
db_kwargs = self._get_db_kwargs()
|
||||
database = self.backend.create_database(db_kwargs)
|
||||
template = self.response_template(CREATE_DATABASE_TEMPLATE)
|
||||
return template.render(database=database)
|
||||
|
||||
def create_dbinstance_read_replica(self):
|
||||
return self.create_db_instance_read_replica()
|
||||
|
||||
def create_db_instance_read_replica(self):
|
||||
db_kwargs = self._get_db_replica_kwargs()
|
||||
|
||||
@ -118,18 +112,12 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(CREATE_DATABASE_REPLICA_TEMPLATE)
|
||||
return template.render(database=database)
|
||||
|
||||
def describe_dbinstances(self):
|
||||
return self.describe_db_instances()
|
||||
|
||||
def describe_db_instances(self):
|
||||
db_instance_identifier = self._get_param('DBInstanceIdentifier')
|
||||
databases = self.backend.describe_databases(db_instance_identifier)
|
||||
template = self.response_template(DESCRIBE_DATABASES_TEMPLATE)
|
||||
return template.render(databases=databases)
|
||||
|
||||
def modify_dbinstance(self):
|
||||
return self.modify_db_instance()
|
||||
|
||||
def modify_db_instance(self):
|
||||
db_instance_identifier = self._get_param('DBInstanceIdentifier')
|
||||
db_kwargs = self._get_db_kwargs()
|
||||
@ -138,18 +126,12 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(MODIFY_DATABASE_TEMPLATE)
|
||||
return template.render(database=database)
|
||||
|
||||
def delete_dbinstance(self):
|
||||
return self.delete_db_instance()
|
||||
|
||||
def delete_db_instance(self):
|
||||
db_instance_identifier = self._get_param('DBInstanceIdentifier')
|
||||
database = self.backend.delete_database(db_instance_identifier)
|
||||
template = self.response_template(DELETE_DATABASE_TEMPLATE)
|
||||
return template.render(database=database)
|
||||
|
||||
def reboot_dbinstance(self):
|
||||
return self.reboot_db_instance()
|
||||
|
||||
def reboot_db_instance(self):
|
||||
db_instance_identifier = self._get_param('DBInstanceIdentifier')
|
||||
database = self.backend.reboot_db_instance(db_instance_identifier)
|
||||
@ -176,9 +158,6 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(REMOVE_TAGS_FROM_RESOURCE_TEMPLATE)
|
||||
return template.render()
|
||||
|
||||
def create_dbsecurity_group(self):
|
||||
return self.create_db_security_group()
|
||||
|
||||
def create_db_security_group(self):
|
||||
group_name = self._get_param('DBSecurityGroupName')
|
||||
description = self._get_param('DBSecurityGroupDescription')
|
||||
@ -188,9 +167,6 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(CREATE_SECURITY_GROUP_TEMPLATE)
|
||||
return template.render(security_group=security_group)
|
||||
|
||||
def describe_dbsecurity_groups(self):
|
||||
return self.describe_db_security_groups()
|
||||
|
||||
def describe_db_security_groups(self):
|
||||
security_group_name = self._get_param('DBSecurityGroupName')
|
||||
security_groups = self.backend.describe_security_groups(
|
||||
@ -198,9 +174,6 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(DESCRIBE_SECURITY_GROUPS_TEMPLATE)
|
||||
return template.render(security_groups=security_groups)
|
||||
|
||||
def delete_dbsecurity_group(self):
|
||||
return self.delete_db_security_group()
|
||||
|
||||
def delete_db_security_group(self):
|
||||
security_group_name = self._get_param('DBSecurityGroupName')
|
||||
security_group = self.backend.delete_security_group(
|
||||
@ -208,9 +181,6 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(DELETE_SECURITY_GROUP_TEMPLATE)
|
||||
return template.render(security_group=security_group)
|
||||
|
||||
def authorize_dbsecurity_group_ingress(self):
|
||||
return self.authorize_db_security_group_ingress()
|
||||
|
||||
def authorize_db_security_group_ingress(self):
|
||||
security_group_name = self._get_param('DBSecurityGroupName')
|
||||
cidr_ip = self._get_param('CIDRIP')
|
||||
@ -219,9 +189,6 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(AUTHORIZE_SECURITY_GROUP_TEMPLATE)
|
||||
return template.render(security_group=security_group)
|
||||
|
||||
def create_dbsubnet_group(self):
|
||||
return self.create_db_subnet_group()
|
||||
|
||||
def create_db_subnet_group(self):
|
||||
subnet_name = self._get_param('DBSubnetGroupName')
|
||||
description = self._get_param('DBSubnetGroupDescription')
|
||||
@ -234,18 +201,12 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(CREATE_SUBNET_GROUP_TEMPLATE)
|
||||
return template.render(subnet_group=subnet_group)
|
||||
|
||||
def describe_dbsubnet_groups(self):
|
||||
return self.describe_db_subnet_groups()
|
||||
|
||||
def describe_db_subnet_groups(self):
|
||||
subnet_name = self._get_param('DBSubnetGroupName')
|
||||
subnet_groups = self.backend.describe_subnet_groups(subnet_name)
|
||||
template = self.response_template(DESCRIBE_SUBNET_GROUPS_TEMPLATE)
|
||||
return template.render(subnet_groups=subnet_groups)
|
||||
|
||||
def delete_dbsubnet_group(self):
|
||||
return self.delete_db_subnet_group()
|
||||
|
||||
def delete_db_subnet_group(self):
|
||||
subnet_name = self._get_param('DBSubnetGroupName')
|
||||
subnet_group = self.backend.delete_subnet_group(subnet_name)
|
||||
@ -307,8 +268,6 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(MODIFY_OPTION_GROUP_TEMPLATE)
|
||||
return template.render(option_group=option_group)
|
||||
|
||||
def create_dbparameter_group(self):
|
||||
return self.create_db_parameter_group()
|
||||
|
||||
def create_db_parameter_group(self):
|
||||
kwargs = self._get_db_parameter_group_kwargs()
|
||||
@ -316,9 +275,6 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(CREATE_DB_PARAMETER_GROUP_TEMPLATE)
|
||||
return template.render(db_parameter_group=db_parameter_group)
|
||||
|
||||
def describe_dbparameter_groups(self):
|
||||
return self.describe_db_parameter_groups()
|
||||
|
||||
def describe_db_parameter_groups(self):
|
||||
kwargs = self._get_db_parameter_group_kwargs()
|
||||
kwargs['max_records'] = self._get_param('MaxRecords')
|
||||
@ -328,9 +284,6 @@ class RDS2Response(BaseResponse):
|
||||
DESCRIBE_DB_PARAMETER_GROUPS_TEMPLATE)
|
||||
return template.render(db_parameter_groups=db_parameter_groups)
|
||||
|
||||
def modify_dbparameter_group(self):
|
||||
return self.modify_db_parameter_group()
|
||||
|
||||
def modify_db_parameter_group(self):
|
||||
db_parameter_group_name = self._get_param('DBParameterGroupName')
|
||||
db_parameter_group_parameters = self._get_db_parameter_group_paramters()
|
||||
@ -353,9 +306,6 @@ class RDS2Response(BaseResponse):
|
||||
|
||||
return parameter_group_parameters.values()
|
||||
|
||||
def describe_dbparameters(self):
|
||||
return self.describe_db_parameters()
|
||||
|
||||
def describe_db_parameters(self):
|
||||
db_parameter_group_name = self._get_param('DBParameterGroupName')
|
||||
db_parameter_groups = self.backend.describe_db_parameter_groups(
|
||||
@ -366,9 +316,6 @@ class RDS2Response(BaseResponse):
|
||||
template = self.response_template(DESCRIBE_DB_PARAMETERS_TEMPLATE)
|
||||
return template.render(db_parameter_group=db_parameter_groups[0])
|
||||
|
||||
def delete_dbparameter_group(self):
|
||||
return self.delete_db_parameter_group()
|
||||
|
||||
def delete_db_parameter_group(self):
|
||||
kwargs = self._get_db_parameter_group_kwargs()
|
||||
db_parameter_group = self.backend.delete_db_parameter_group(kwargs[
|
||||
|
@ -11,6 +11,7 @@ def test_camelcase_to_underscores():
|
||||
"theNewAttribute": "the_new_attribute",
|
||||
"attri bute With Space": "attribute_with_space",
|
||||
"FirstLetterCapital": "first_letter_capital",
|
||||
"ListMFADevices": "list_mfa_devices",
|
||||
}
|
||||
for arg, expected in cases.items():
|
||||
camelcase_to_underscores(arg).should.equal(expected)
|
||||
|
Loading…
Reference in New Issue
Block a user