Back to Black
This commit is contained in:
parent
ea489bce6c
commit
5697ff87a8
112 changed files with 1803 additions and 977 deletions
|
|
@ -7,12 +7,18 @@ import boto3
|
|||
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
alternative_service_names = {'lambda': 'awslambda', 'dynamodb': 'dynamodb2'}
|
||||
alternative_service_names = {"lambda": "awslambda", "dynamodb": "dynamodb2"}
|
||||
|
||||
|
||||
def get_moto_implementation(service_name):
|
||||
service_name = service_name.replace("-", "") if "-" in service_name else service_name
|
||||
alt_service_name = alternative_service_names[service_name] if service_name in alternative_service_names else service_name
|
||||
service_name = (
|
||||
service_name.replace("-", "") if "-" in service_name else service_name
|
||||
)
|
||||
alt_service_name = (
|
||||
alternative_service_names[service_name]
|
||||
if service_name in alternative_service_names
|
||||
else service_name
|
||||
)
|
||||
if hasattr(moto, "mock_{}".format(alt_service_name)):
|
||||
mock = getattr(moto, "mock_{}".format(alt_service_name))
|
||||
elif hasattr(moto, "mock_{}".format(service_name)):
|
||||
|
|
@ -31,11 +37,13 @@ def calculate_implementation_coverage():
|
|||
coverage = {}
|
||||
for service_name in service_names:
|
||||
moto_client = get_moto_implementation(service_name)
|
||||
real_client = boto3.client(service_name, region_name='us-east-1')
|
||||
real_client = boto3.client(service_name, region_name="us-east-1")
|
||||
implemented = []
|
||||
not_implemented = []
|
||||
|
||||
operation_names = [xform_name(op) for op in real_client.meta.service_model.operation_names]
|
||||
operation_names = [
|
||||
xform_name(op) for op in real_client.meta.service_model.operation_names
|
||||
]
|
||||
for op in operation_names:
|
||||
if moto_client and op in dir(moto_client):
|
||||
implemented.append(op)
|
||||
|
|
@ -43,20 +51,22 @@ def calculate_implementation_coverage():
|
|||
not_implemented.append(op)
|
||||
|
||||
coverage[service_name] = {
|
||||
'implemented': implemented,
|
||||
'not_implemented': not_implemented,
|
||||
"implemented": implemented,
|
||||
"not_implemented": not_implemented,
|
||||
}
|
||||
return coverage
|
||||
|
||||
|
||||
def print_implementation_coverage(coverage):
|
||||
for service_name in sorted(coverage):
|
||||
implemented = coverage.get(service_name)['implemented']
|
||||
not_implemented = coverage.get(service_name)['not_implemented']
|
||||
implemented = coverage.get(service_name)["implemented"]
|
||||
not_implemented = coverage.get(service_name)["not_implemented"]
|
||||
operations = sorted(implemented + not_implemented)
|
||||
|
||||
if implemented and not_implemented:
|
||||
percentage_implemented = int(100.0 * len(implemented) / (len(implemented) + len(not_implemented)))
|
||||
percentage_implemented = int(
|
||||
100.0 * len(implemented) / (len(implemented) + len(not_implemented))
|
||||
)
|
||||
elif implemented:
|
||||
percentage_implemented = 100
|
||||
else:
|
||||
|
|
@ -84,12 +94,14 @@ def write_implementation_coverage_to_file(coverage):
|
|||
print("Writing to {}".format(implementation_coverage_file))
|
||||
with open(implementation_coverage_file, "w+") as file:
|
||||
for service_name in sorted(coverage):
|
||||
implemented = coverage.get(service_name)['implemented']
|
||||
not_implemented = coverage.get(service_name)['not_implemented']
|
||||
implemented = coverage.get(service_name)["implemented"]
|
||||
not_implemented = coverage.get(service_name)["not_implemented"]
|
||||
operations = sorted(implemented + not_implemented)
|
||||
|
||||
if implemented and not_implemented:
|
||||
percentage_implemented = int(100.0 * len(implemented) / (len(implemented) + len(not_implemented)))
|
||||
percentage_implemented = int(
|
||||
100.0 * len(implemented) / (len(implemented) + len(not_implemented))
|
||||
)
|
||||
elif implemented:
|
||||
percentage_implemented = 100
|
||||
else:
|
||||
|
|
@ -98,7 +110,9 @@ def write_implementation_coverage_to_file(coverage):
|
|||
file.write("\n")
|
||||
file.write("## {}\n".format(service_name))
|
||||
file.write("<details>\n")
|
||||
file.write("<summary>{}% implemented</summary>\n\n".format(percentage_implemented))
|
||||
file.write(
|
||||
"<summary>{}% implemented</summary>\n\n".format(percentage_implemented)
|
||||
)
|
||||
for op in operations:
|
||||
if op in implemented:
|
||||
file.write("- [X] {}\n".format(op))
|
||||
|
|
@ -107,7 +121,7 @@ def write_implementation_coverage_to_file(coverage):
|
|||
file.write("</details>\n")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
cov = calculate_implementation_coverage()
|
||||
write_implementation_coverage_to_file(cov)
|
||||
print_implementation_coverage(cov)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue