def _setup_github(): settings = Settings() if settings.is_github_valid(): if not click.confirm("Reset GitHub config?", prompt_suffix=" "): return click.echo(get_github_text()) token = click.prompt("GitHub token", type=click.STRING, hide_input=True).strip() settings.set_github_token(token) try: login_query = LoginQuery() login_query.execute() # pylint: disable=no-value-for-parameter login = login_query.get_login() email_query = EmailQuery() email_query.execute() # pylint: disable=no-value-for-parameter except Exception as exception: settings.reset_github() raise exception settings.set_github_login(login) settings.set_github_emails(email_query.get_emails()) click.secho("✓ GitHub, hello {}! 💕✨".format(login), bold=True)
def test_set_get_reset_settings(): settings = Settings() settings.set_github_token("github_token") settings.set_github_login("github_login") settings.set_github_emails( ["github_email1", "github_email2", "github_email3"]) assert settings.is_github_valid() assert not settings.is_slack_valid() assert settings.get_github_token() == "github_token" assert settings.get_github_login() == "github_login" assert settings.get_github_emails() == [ "github_email1", "github_email2", "github_email3" ] settings.set_slack_token("slack_token") settings.set_slack_channel("slack_channel") assert settings.is_github_valid() assert settings.is_slack_valid() assert settings.get_slack_token() == "slack_token" assert settings.get_slack_channel() == "slack_channel" settings.reset_slack() assert not settings.is_slack_valid() settings.reset_github() assert not settings.is_github_valid() assert_empty_settings()
def fill_settings(): settings = Settings() settings.set_github_emails( ["*****@*****.**", "*****@*****.**", "*****@*****.**"]) settings.set_github_login("user1") settings.set_github_token("github_token") settings.set_slack_token("slack_token") settings.set_slack_channel("slack_channel")