Add OAuth2 config flow scaffold (#28220)

* Add OAuth2 scaffold

* Generate integration if non-existing domain specified

* Update URL
This commit is contained in:
Paulus Schoutsen 2019-10-29 20:34:03 -07:00 committed by GitHub
parent e700384cce
commit 24c29f9227
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 567 additions and 209 deletions

View file

@ -48,34 +48,46 @@ def main():
args = get_arguments()
info = gather_info.gather_info(args)
print()
generate.generate(args.template, info)
# If we are calling scaffold on a non-existing integration,
# We're going to first make it. If we're making an integration,
# we will also make a config flow to go with it.
# If creating new integration, create config flow too
if args.template == "integration":
if info.authentication or not info.discoverable:
template = "config_flow"
else:
template = "config_flow_discovery"
if info.is_new:
generate.generate("integration", info)
generate.generate(template, info)
# If it's a new integration and it's not a config flow,
# create a config flow too.
if not args.template.startswith("config_flow"):
if info.oauth2:
template = "config_flow_oauth2"
elif info.authentication or not info.discoverable:
template = "config_flow"
else:
template = "config_flow_discovery"
generate.generate(template, info)
# If we wanted a new integration, we've already done our work.
if args.template != "integration":
generate.generate(args.template, info)
pipe_null = "" if args.develop else "> /dev/null"
print("Running hassfest to pick up new information.")
subprocess.run("python -m script.hassfest", shell=True)
subprocess.run(f"python -m script.hassfest {pipe_null}", shell=True)
print()
print("Running tests")
print(f"$ pytest -vvv tests/components/{info.domain}")
if (
subprocess.run(
f"pytest -vvv tests/components/{info.domain}", shell=True
).returncode
!= 0
):
return 1
print("Running gen_requirements_all to pick up new information.")
subprocess.run(f"python -m script.gen_requirements_all {pipe_null}", shell=True)
print()
print(f"Done!")
if args.develop:
print("Running tests")
print(f"$ pytest -vvv tests/components/{info.domain}")
subprocess.run(f"pytest -vvv tests/components/{info.domain}", shell=True)
print()
docs.print_relevant_docs(args.template, info)