From 7b36f6b790b45e9ab0102c1313d1276698da0fd6 Mon Sep 17 00:00:00 2001 From: Jack Danger Date: Fri, 14 Jul 2017 10:54:10 -0700 Subject: [PATCH 1/2] Adding implementation_coverage.py script --- implementation_coverage.py | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 implementation_coverage.py diff --git a/implementation_coverage.py b/implementation_coverage.py new file mode 100644 index 000000000..d56e442a8 --- /dev/null +++ b/implementation_coverage.py @@ -0,0 +1,68 @@ +import moto +from botocore import xform_name +from botocore.session import Session +import boto3 + + +def get_moto_implementation(service_name): + if not hasattr(moto, service_name): + return None + module = getattr(moto, service_name) + if module is None: + return None + mock = getattr(module, "mock_{}".format(service_name)) + if mock is None: + return None + backends = list(mock().backends.values()) + if backends: + return backends[0] + + +def calculate_implementation_coverage(): + service_names = Session().get_available_services() + 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') + implemented = [] + not_implemented = [] + + 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) + else: + not_implemented.append(op) + + coverage[service_name] = { + 'implemented': implemented, + 'not_implemented': not_implemented, + } + return coverage + + +def print_implementation_coverage(): + coverage = calculate_implementation_coverage() + for service_name in coverage: + 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))) + elif implemented: + percentage_implemented = 100 + else: + percentage_implemented = 0 + + print("-----------------------") + print("{} - {}% implemented".format(service_name, percentage_implemented)) + print("-----------------------") + for op in operations: + if op in implemented: + print("[X] {}".format(op)) + else: + print("[ ] {}".format(op)) + +if __name__ == '__main__': + print_implementation_coverage() From 7a3f6e6e47779d7d4918dfb66c165fe1da77a178 Mon Sep 17 00:00:00 2001 From: Jack Danger Date: Mon, 14 Aug 2017 14:51:50 -0700 Subject: [PATCH 2/2] making script executable --- implementation_coverage.py | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 implementation_coverage.py diff --git a/implementation_coverage.py b/implementation_coverage.py old mode 100644 new mode 100755 index d56e442a8..f0d22fc95 --- a/implementation_coverage.py +++ b/implementation_coverage.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python import moto from botocore import xform_name from botocore.session import Session