[MERGE] Add a get_login method to UIFactory and test get_password

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Feb 20 08:03:10 GMT 2007


>>>>> "Martin" == Martin Pool <mbp at canonical.com> writes:

    Martin> On 19 Feb 2007, Vincent Ladeuil <v.ladeuil+lp at free.fr> wrote:
    >> I needed to write tests involving querying user for login and
    >> password.
    >> 
    >> I rewrote part of the tests in the process so that they can be
    >> run from a dumb terminal (I get tired of
    >> test_text_factory_prompts_and_clears failures).

    Martin> That sounds reasonable.  Does anything call these
    Martin> already or are they new?

get_password is used for ftp, ssh and http. get_login is needed to
address bug #72792. I tried to isolate that patch to ease review.

    >> Unicode experts comments welcome.
    >> 

    >> One point I couldn't decide was: should the login and
    >> passwords be encoded ?

    Martin> I'm not sure.  I think your position is a reasonable
    Martin> place to start.

Let's start with that then.

<snip/>

    >> """See UIFactory.nested_progress_bar()."""
    >> raise NotImplementedError(self.progress_bar)
    >> 
    >> +    def get_login(self, prompt='', **kwargs):
    >> +        """Prompt the user for a login (generally on a remote host).
    >> +
    >> +        :param prompt: The prompt to present the user
    >> +        :param kwargs: Arguments which will be expanded into the prompt.
    >> +                       This lets front ends display different things if
    >> +                       they so choose.
    >> +

    Martin> Rather than passing the prompt and kwargs to these
    Martin> methods why not let the caller combine them?

I think the original intent in get_password (which I duplicated)
was to "let different front ends display different things". I'm
+0.5 on this until I see useful examples.

Note that get_boolean add a '[y\n] ?' and that get_login and
get_password add a ': ' at the end of the prompt which seems
appropriate for CLI.

But that's a different point than kwargs though.

    >> +        :return: The user string, return None if the user canceled the
    >> +                 request. Note that we do not touch the encoding, users may
    >> +                 have whatever they see fit and the password should be
    >> +                 transported as is. 
    >> +        """
    >> +        raise NotImplementedError(self.progress_bar)

    Martin> Should be self.get_login.

Oops, thanks.

      Vincent

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 185 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070220/3d5ffda5/attachment-0001.pgp 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fakestdin.patch
Type: text/x-patch
Size: 36152 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070220/3d5ffda5/attachment-0001.bin 


More information about the bazaar mailing list