def _registry_init(username: str, no_subscribe: bool) -> None: """ Create an author name on the registry. :param author: the author name :param no_subscribe: bool flag for developers subscription skip on register. :return: None. """ if username is not None and is_auth_token_present(): check_is_author_logged_in(username) else: is_registered = click.confirm("Do you have a Registry account?") if is_registered: password = click.prompt("Password", type=str, hide_input=True) do_login(username, password) else: click.echo("Create a new account on the Registry now:") email = click.prompt("Email", type=str) password = click.prompt("Password", type=str, hide_input=True) password_confirmation = "" # nosec while password_confirmation != password: click.echo("Please make sure that passwords are equal.") password_confirmation = click.prompt("Confirm password", type=str, hide_input=True) do_register(username, email, password, password_confirmation, no_subscribe)
def test_do_register_positive(self, update_cli_config_mock, *mocks): """Test for do_register method positive result.""" username = "******" email = "*****@*****.**" fake_pwd = "fake_pwd" # nosec do_register(username, email, fake_pwd, fake_pwd) update_cli_config_mock.assert_called_once_with({AUTH_TOKEN_KEY: "token"})
def test_do_register_no_subscribe_true_positive(self, update_cli_config_mock, confirm_mock, echo_mock, *mocks): """Test for do_register method no_subscribe flag = True positive result.""" username = "******" email = "*****@*****.**" fake_pwd = "fake_pwd" # nosec no_subscribe = True do_register(username, email, fake_pwd, fake_pwd, no_subscribe) update_cli_config_mock.assert_called_once_with( {AUTH_TOKEN_KEY: "token"}) confirm_mock.assert_not_called()