/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Jan Balster
  • Date: 2006-08-15 12:39:42 UTC
  • mfrom: (1923 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1928.
  • Revision ID: jan@merlinux.de-20060815123942-22c388c6e9a8ac91
merge bzr.dev 1923

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 (
 
27
    config,
 
28
    errors,
 
29
    osutils,
 
30
    urlutils,
 
31
    )
27
32
from bzrlib.branch import Branch
28
33
from bzrlib.bzrdir import BzrDir
29
 
import bzrlib.errors as errors
30
 
from bzrlib.tests import TestCase, TestCaseInTempDir
 
34
from bzrlib.tests import TestCase, TestCaseInTempDir, TestCaseWithTransport
31
35
 
32
36
 
33
37
sample_long_alias="log -r-15..-1 --line"
321
325
                                          'utf-8')])
322
326
 
323
327
 
324
 
class TestBranchConfig(TestCaseInTempDir):
 
328
class TestBranchConfig(TestCaseWithTransport):
325
329
 
326
330
    def test_constructs(self):
327
331
        branch = FakeBranch()
348
352
        my_config2 = b2.get_config()
349
353
        self.assertEqual(my_config2.get_user_option('wacky'), 'unlikely')
350
354
 
 
355
    def test_has_explicit_nickname(self):
 
356
        b = self.make_branch('.')
 
357
        self.assertFalse(b.get_config().has_explicit_nickname())
 
358
        b.nick = 'foo'
 
359
        self.assertTrue(b.get_config().has_explicit_nickname())
 
360
 
 
361
    def test_config_url(self):
 
362
        """The Branch.get_config will use section that uses a local url"""
 
363
        branch = self.make_branch('branch')
 
364
        self.assertEqual('branch', branch.nick)
 
365
 
 
366
        locations = config.locations_config_filename()
 
367
        config.ensure_config_dir_exists()
 
368
        local_url = urlutils.local_path_to_url('branch')
 
369
        open(locations, 'wb').write('[%s]\nnickname = foobar' 
 
370
                                    % (local_url,))
 
371
        self.assertEqual('foobar', branch.nick)
 
372
 
 
373
    def test_config_local_path(self):
 
374
        """The Branch.get_config will use a local system path"""
 
375
        branch = self.make_branch('branch')
 
376
        self.assertEqual('branch', branch.nick)
 
377
 
 
378
        locations = config.locations_config_filename()
 
379
        config.ensure_config_dir_exists()
 
380
        open(locations, 'wb').write('[%s/branch]\nnickname = barry' 
 
381
                                    % (osutils.getcwd().encode('utf8'),))
 
382
        self.assertEqual('barry', branch.nick)
 
383
 
 
384
    def test_config_creates_local(self):
 
385
        """Creating a new entry in config uses a local path."""
 
386
        branch = self.make_branch('branch')
 
387
        branch.set_push_location('http://foobar')
 
388
        locations = config.locations_config_filename()
 
389
        local_path = osutils.getcwd().encode('utf8')
 
390
        # Surprisingly ConfigObj doesn't create a trailing newline
 
391
        self.check_file_contents(locations,
 
392
            '[%s/branch]\npush_location = http://foobar' % (local_path,))
 
393
 
351
394
 
352
395
class TestGlobalConfigItems(TestCase):
353
396
 
473
516
        self.assertEqual(parser._calls,
474
517
                         [('__init__', config.locations_config_filename(),
475
518
                           'utf-8')])
476
 
        os.mkdir(config.config_dir())
 
519
        config.ensure_config_dir_exists()
 
520
        #os.mkdir(config.config_dir())
477
521
        f = file(config.branches_config_filename(), 'wb')
478
522
        f.write('')
479
523
        f.close()
706
750
        my_config.branch.control_files.email = "John"
707
751
        self.assertEqual("John", my_config._get_user_id())
708
752
 
709
 
    def test_BZREMAIL_OVERRIDES(self):
710
 
        os.environ['BZREMAIL'] = "Robert Collins <robertc@example.org>"
 
753
    def test_BZR_EMAIL_OVERRIDES(self):
 
754
        os.environ['BZR_EMAIL'] = "Robert Collins <robertc@example.org>"
711
755
        branch = FakeBranch()
712
756
        my_config = config.BranchConfig(branch)
713
757
        self.assertEqual("Robert Collins <robertc@example.org>",