diff --git a/examples/ReferenceTestV2/run.py b/examples/ReferenceTestV2/run.py index 0f4a01a6..20e323bf 100644 --- a/examples/ReferenceTestV2/run.py +++ b/examples/ReferenceTestV2/run.py @@ -7,39 +7,41 @@ import threading import uuid +from examples.ReferenceTestV2 import reference_consumer_v2, reference_provider_v2 from sdc11073 import network -from examples.ReferenceTestV2 import reference_provider_v2, reference_consumer_v2 - def setup(tls: bool): - os.environ['ref_search_epr'] = str(uuid.uuid4()) - if platform.system() == 'Darwin': - os.environ['ref_ip'] = next(str(adapter.ip) for adapter in network.get_adapters() if not adapter.is_loopback) + """Setups the run.""" + os.environ["ref_search_epr"] = str(uuid.uuid4()) # noqa: SIM112 + if platform.system() == "Darwin": + os.environ["ref_ip"] = next(str(adapter.ip) for adapter in network.get_adapters() if not adapter.is_loopback) # noqa: SIM112 else: - os.environ['ref_ip'] = next(str(adapter.ip) for adapter in network.get_adapters() if adapter.is_loopback) + os.environ["ref_ip"] = next(str(adapter.ip) for adapter in network.get_adapters() if adapter.is_loopback) # noqa: SIM112 if tls: - certs_path = pathlib.Path(__file__).parent.parent.joinpath('certs') + certs_path = pathlib.Path(__file__).parent.parent.joinpath("certs") assert certs_path.exists() - os.environ['ref_ca'] = str(certs_path) - os.environ['ref_ssl_passwd'] = 'dummypass' + os.environ["ref_ca"] = str(certs_path) # noqa: SIM112 + os.environ["ref_ssl_passwd"] = "dummypass" # noqa: S105,SIM112 def run() -> reference_consumer_v2.ResultsCollector: + """Run tests.""" threading.Thread(target=reference_provider_v2.run_provider, daemon=True).start() return reference_consumer_v2.run_ref_test(reference_consumer_v2.ResultsCollector()) -def main(tls: bool): +def main(tls: bool) -> reference_consumer_v2.ResultsCollector: + """Setups and run tests.""" setup(tls) return run() -if __name__ == '__main__': +if __name__ == "__main__": import argparse - parser = argparse.ArgumentParser(description='run plug-a-thon tests') - parser.add_argument('--tls', action='store_true', help='Indicates whether tls encryption should be enabled.') + parser = argparse.ArgumentParser(description="run plug-a-thon tests") + parser.add_argument("--tls", action="store_true", help="Indicates whether tls encryption should be enabled.") args = parser.parse_args() run_results = main(tls=args.tls)