示例#1
0
    def test_validate_author_name_negative(self, prompt_mock):
        """Test validate_author_name for negative result."""
        with self.assertRaises(StopTest):
            validate_author_name()

        prompt_mock.return_value = "skills"
        with self.assertRaises(StopTest):
            validate_author_name()
示例#2
0
    def test_validate_author_name_positive(self, prompt_mock):
        """Test validate_author_name for positive result."""
        author = "valid_author"
        result = validate_author_name(author=author)
        self.assertEqual(result, author)

        result = validate_author_name()
        self.assertEqual(result, "correct_author")
        prompt_mock.assert_called_once()
示例#3
0
def do_register(
    username: str,
    email: str,
    password: str,
    password_confirmation: str,
    no_subscribe: bool,
) -> None:
    """
    Register a new Registry account and save auth token.

    :param username: str username.
    :param email: str email.
    :param password: str password.
    :param password_confirmation: str password confirmation.
    :param no_subscribe: bool flag for developers subscription skip on register.

    :return: None
    """
    username = validate_author_name(username)
    token = register_new_account(username, email, password,
                                 password_confirmation)
    update_cli_config({AUTH_TOKEN_KEY: token})
    if not no_subscribe and click.confirm(
            "Do you want to subscribe for developer news?"):
        click.echo("Please visit `https://aea-registry.fetch.ai/mailing-list` "
                   "to subscribe for developer news")
    click.echo("Successfully registered and logged in: {}".format(username))
示例#4
0
def do_init(author: str, reset: bool, registry: bool,
            no_subscribe: bool) -> None:
    """
    Initialize your AEA configurations.

    :param author: str author username.
    :param reset: True, if resetting the author name
    :param registry: True, if registry is used
    :param no_subscribe: bool flag for developers subscription skip on register.

    :return: None.
    """
    config = get_or_create_cli_config()
    if reset or config.get(AUTHOR_KEY, None) is None:
        author = validate_author_name(author)
        if registry:
            _registry_init(username=author, no_subscribe=no_subscribe)

        update_cli_config({AUTHOR_KEY: author})
        config = get_or_create_cli_config()
        config.pop(AUTH_TOKEN_KEY, None)  # for security reasons
        success_msg = "AEA configurations successfully initialized: {}".format(
            config)
    else:
        config.pop(AUTH_TOKEN_KEY, None)  # for security reasons
        success_msg = "AEA configurations already initialized: {}. To reset use '--reset'.".format(
            config)
    click.echo(AEA_LOGO + "v" + __version__ + "\n")
    click.echo(success_msg)
示例#5
0
def do_register(
    username: str, email: str, password: str, password_confirmation: str
) -> None:
    """
    Register a new Registry account and save auth token.

    :param username: str username.
    :param email: str email.
    :param password: str password.
    :param password_confirmation: str password confirmation.

    :return: None
    """
    username = validate_author_name(username)
    token = register_new_account(username, email, password, password_confirmation)
    update_cli_config({AUTH_TOKEN_KEY: token})
    click.echo("Successfully registered and logged in: {}".format(username))