~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Wouter van Heyst
  • Date: 2006-06-06 12:06:20 UTC
  • mfrom: (1740 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060606120620-50066b0951e4ef7c
merge bzr.dev 1740

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Ltd
 
1
# Copyright (C) 2005, 2006 by Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
396
396
        my_config = self._get_sample_config()
397
397
        self.assertEqual(sample_long_alias, my_config.get_alias('ll'))
398
398
 
399
 
class TestLocationConfig(TestCase):
 
399
 
 
400
class TestLocationConfig(TestCaseInTempDir):
400
401
 
401
402
    def test_constructs(self):
402
403
        my_config = config.LocationConfig('http://example.com')
416
417
            config.ConfigObj = oldparserclass
417
418
        self.failUnless(isinstance(parser, InstrumentedConfigObj))
418
419
        self.assertEqual(parser._calls,
419
 
                         [('__init__', config.branches_config_filename())])
 
420
                         [('__init__', config.branches_config_filename(),
 
421
                           'utf-8')])
420
422
 
421
423
    def test_get_global_config(self):
422
424
        my_config = config.LocationConfig('http://example.com')
473
475
        self.get_location_config('/a/c')
474
476
        self.assertEqual('/a/c', self.my_config._get_section())
475
477
 
476
 
    def get_location_config(self, location, global_config=None):
477
 
        if global_config is None:
478
 
            global_file = StringIO(sample_config_text)
479
 
        else:
480
 
            global_file = StringIO(global_config)
481
 
        branches_file = StringIO(sample_branches_text)
482
 
        self.my_config = config.LocationConfig(location)
483
 
        self.my_config._get_parser(branches_file)
484
 
        self.my_config._get_global_config()._get_parser(global_file)
485
478
 
486
479
    def test_location_without_username(self):
487
480
        self.get_location_config('http://www.example.com/useglobal')
488
 
        self.assertEqual('Robert Collins <robertc@example.com>',
 
481
        self.assertEqual(u'Erik B\u00e5gfors <erik@bagfors.nu>',
489
482
                         self.my_config.username())
490
483
 
491
484
    def test_location_not_listed(self):
 
485
        """Test that the global username is used when no location matches"""
492
486
        self.get_location_config('/home/robertc/sources')
493
 
        self.assertEqual('Robert Collins <robertc@example.com>',
 
487
        self.assertEqual(u'Erik B\u00e5gfors <erik@bagfors.nu>',
494
488
                         self.my_config.username())
495
489
 
496
490
    def test_overriding_location(self):
542
536
        self.assertEqual('bzrlib.tests.test_config.post_commit',
543
537
                         self.my_config.post_commit())
544
538
 
545
 
 
546
 
class TestLocationConfig(TestCaseInTempDir):
547
 
 
548
539
    def get_location_config(self, location, global_config=None):
549
540
        if global_config is None:
550
541
            global_file = StringIO(sample_config_text.encode('utf-8'))