~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_xml.py

  • Committer: Vincent Ladeuil
  • Date: 2009-04-27 16:10:10 UTC
  • mto: (4310.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4311.
  • Revision ID: v.ladeuil+lp@free.fr-20090427161010-7swfzeagf63cpixd
Fix bug #367726 by reverting some default user handling introduced
while fixing bug #256612.

* bzrlib/transport/ssh.py:
(_paramiko_auth): Explicitly use getpass.getuser() as default
user.

* bzrlib/transport/ftp/_gssapi.py:
(GSSAPIFtpTransport._create_connection): Explicitly use
getpass.getuser() as default user.

* bzrlib/transport/ftp/__init__.py:
(FtpTransport._create_connection): Explicitly use
getpass.getuser() as default user.

* bzrlib/tests/test_sftp_transport.py:
(TestUsesAuthConfig.test_sftp_is_none_if_no_config)
(TestUsesAuthConfig.test_sftp_doesnt_prompt_username): Revert to
None as the default user.

* bzrlib/tests/test_remote.py:
(TestRemoteSSHTransportAuthentication): The really offending one:
revert to None as the default user.

* bzrlib/tests/test_config.py:
(TestAuthenticationConfig.test_username_default_no_prompt): Update
test (and some PEP8).

* bzrlib/smtp_connection.py:
(SMTPConnection._authenticate): Revert to None as the default
user.

* bzrlib/plugins/launchpad/account.py:
(_get_auth_user): Revert default value handling.

* bzrlib/config.py:
(AuthenticationConfig.get_user): Fix doc-string. Leave default
value handling to callers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
 
19
19
from bzrlib import (
20
20
    errors,
21
 
    fifo_cache,
22
21
    inventory,
23
 
    xml6,
24
22
    xml7,
25
23
    xml8,
26
24
    serializer,
141
139
</inventory>
142
140
"""
143
141
 
144
 
_expected_inv_v6 = """<inventory format="6" revision_id="rev_outer">
145
 
<directory file_id="tree-root-321" name="" revision="rev_outer" />
146
 
<directory file_id="dir-id" name="dir" parent_id="tree-root-321" revision="rev_outer" />
147
 
<file file_id="file-id" name="file" parent_id="tree-root-321" revision="rev_outer" text_sha1="A" text_size="1" />
148
 
<symlink file_id="link-id" name="link" parent_id="tree-root-321" revision="rev_outer" symlink_target="a" />
149
 
</inventory>
150
 
"""
151
 
 
152
142
_expected_inv_v7 = """<inventory format="7" revision_id="rev_outer">
153
143
<directory file_id="tree-root-321" name="" revision="rev_outer" />
154
144
<directory file_id="dir-id" name="dir" parent_id="tree-root-321" revision="rev_outer" />
291
281
                _inventory_v5a, revision_id='test-rev-id')
292
282
        self.assertEqual('test-rev-id', inv.root.revision)
293
283
 
294
 
    def test_unpack_inventory_5a_cache_and_copy(self):
295
 
        # Passing an entry_cache should get populated with the objects
296
 
        # But the returned objects should be copies if return_from_cache is
297
 
        # False
298
 
        entry_cache = fifo_cache.FIFOCache()
299
 
        inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
300
 
            _inventory_v5a, revision_id='test-rev-id',
301
 
            entry_cache=entry_cache, return_from_cache=False)
302
 
        for entry in inv.iter_just_entries():
303
 
            key = (entry.file_id, entry.revision)
304
 
            if entry.file_id is inv.root.file_id:
305
 
                # The root id is inferred for xml v5
306
 
                self.assertFalse(key in entry_cache)
307
 
            else:
308
 
                self.assertIsNot(entry, entry_cache[key])
309
 
 
310
 
    def test_unpack_inventory_5a_cache_no_copy(self):
311
 
        # Passing an entry_cache should get populated with the objects
312
 
        # The returned objects should be exact if return_from_cache is
313
 
        # True
314
 
        entry_cache = fifo_cache.FIFOCache()
315
 
        inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
316
 
            _inventory_v5a, revision_id='test-rev-id',
317
 
            entry_cache=entry_cache, return_from_cache=True)
318
 
        for entry in inv.iter_just_entries():
319
 
            key = (entry.file_id, entry.revision)
320
 
            if entry.file_id is inv.root.file_id:
321
 
                # The root id is inferred for xml v5
322
 
                self.assertFalse(key in entry_cache)
323
 
            else:
324
 
                self.assertIs(entry, entry_cache[key])
325
 
 
326
284
    def test_unpack_inventory_5b(self):
327
285
        inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(
328
286
                _inventory_v5b, revision_id='test-rev-id')
419
377
        for path, ie in inv.iter_entries():
420
378
            self.assertEqual(ie, inv2[ie.file_id])
421
379
 
422
 
    def test_roundtrip_inventory_v6(self):
423
 
        inv = self.get_sample_inventory()
424
 
        txt = xml6.serializer_v6.write_inventory_to_string(inv)
425
 
        lines = xml6.serializer_v6.write_inventory_to_lines(inv)
426
 
        self.assertEqual(bzrlib.osutils.split_lines(txt), lines)
427
 
        self.assertEqualDiff(_expected_inv_v6, txt)
428
 
        inv2 = xml6.serializer_v6.read_inventory_from_string(txt)
429
 
        self.assertEqual(4, len(inv2))
430
 
        for path, ie in inv.iter_entries():
431
 
            self.assertEqual(ie, inv2[ie.file_id])
432
 
 
433
380
    def test_wrong_format_v7(self):
434
381
        """Can't accidentally open a file with wrong serializer"""
435
382
        s_v6 = bzrlib.xml6.serializer_v6