~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-21 17:52:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1882.
  • Revision ID: john@arbash-meinel.com-20060721175222-bf7499a71473f2f0
Entries in locations.conf should prefer local paths if available (bug #53653)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import sys
24
24
 
25
25
#import bzrlib specific imports here
26
 
import bzrlib.config as config
 
26
from bzrlib import config, errors, osutils, urlutils
27
27
from bzrlib.branch import Branch
28
28
from bzrlib.bzrdir import BzrDir
29
 
import bzrlib.errors as errors
30
29
from bzrlib.tests import TestCase, TestCaseInTempDir, TestCaseWithTransport
31
30
 
32
31
 
354
353
        b.nick = 'foo'
355
354
        self.assertTrue(b.get_config().has_explicit_nickname())
356
355
 
 
356
    def test_config_url(self):
 
357
        """The Branch.get_config will use section that uses a local url"""
 
358
        branch = self.make_branch('branch')
 
359
        self.assertEqual('branch', branch.nick)
 
360
 
 
361
        locations = config.locations_config_filename()
 
362
        config.ensure_config_dir_exists()
 
363
        local_url = urlutils.local_path_to_url('branch')
 
364
        open(locations, 'wb').write('[%s]\nnickname = foobar' 
 
365
                                    % (local_url,))
 
366
        self.assertEqual('foobar', branch.nick)
 
367
 
 
368
    def test_config_local_path(self):
 
369
        """The Branch.get_config will use a local system path"""
 
370
        branch = self.make_branch('branch')
 
371
        self.assertEqual('branch', branch.nick)
 
372
 
 
373
        locations = config.locations_config_filename()
 
374
        config.ensure_config_dir_exists()
 
375
        open(locations, 'wb').write('[%s/branch]\nnickname = barry' 
 
376
                                    % (osutils.getcwd().encode('utf8'),))
 
377
        self.assertEqual('barry', branch.nick)
 
378
 
357
379
 
358
380
class TestGlobalConfigItems(TestCase):
359
381