535
537
self.failUnless(isinstance(global_config, config.GlobalConfig))
536
538
self.failUnless(global_config is my_config._get_global_config())
538
def test__get_section_no_match(self):
540
def test__get_matching_sections_no_match(self):
539
541
self.get_branch_config('/')
540
self.assertEqual(None, self.my_location_config._get_section())
542
self.assertEqual([], self.my_location_config._get_matching_sections())
542
def test__get_section_exact(self):
544
def test__get_matching_sections_exact(self):
543
545
self.get_branch_config('http://www.example.com')
544
self.assertEqual('http://www.example.com',
545
self.my_location_config._get_section())
546
self.assertEqual([('http://www.example.com', '')],
547
self.my_location_config._get_matching_sections())
547
def test__get_section_suffix_does_not(self):
549
def test__get_matching_sections_suffix_does_not(self):
548
550
self.get_branch_config('http://www.example.com-com')
549
self.assertEqual(None, self.my_location_config._get_section())
551
self.assertEqual([], self.my_location_config._get_matching_sections())
551
def test__get_section_subdir_recursive(self):
553
def test__get_matching_sections_subdir_recursive(self):
552
554
self.get_branch_config('http://www.example.com/com')
553
self.assertEqual('http://www.example.com',
554
self.my_location_config._get_section())
556
def test__get_section_subdir_matches(self):
557
self.get_branch_config('http://www.example.com/useglobal')
558
self.assertEqual('http://www.example.com/useglobal',
559
self.my_location_config._get_section())
561
def test__get_section_subdir_nonrecursive(self):
562
self.get_branch_config(
563
'http://www.example.com/useglobal/childbranch')
564
self.assertEqual('http://www.example.com',
565
self.my_location_config._get_section())
567
def test__get_section_subdir_trailing_slash(self):
555
self.assertEqual([('http://www.example.com', 'com')],
556
self.my_location_config._get_matching_sections())
558
def test__get_matching_sections_ignoreparent(self):
559
self.get_branch_config('http://www.example.com/ignoreparent')
560
self.assertEqual([('http://www.example.com/ignoreparent', '')],
561
self.my_location_config._get_matching_sections())
563
def test__get_matching_sections_ignoreparent_subdir(self):
564
self.get_branch_config(
565
'http://www.example.com/ignoreparent/childbranch')
566
self.assertEqual([('http://www.example.com/ignoreparent', 'childbranch')],
567
self.my_location_config._get_matching_sections())
569
def test__get_matching_sections_norecurse(self):
570
self.get_branch_config('http://www.example.com/norecurse')
571
self.assertEqual([('http://www.example.com/norecurse', ''),
572
('http://www.example.com', 'norecurse')],
573
self.my_location_config._get_matching_sections())
575
def test__get_matching_sections_norecurse_subdir(self):
576
self.get_branch_config(
577
'http://www.example.com/norecurse/childbranch')
578
self.assertEqual([('http://www.example.com', 'norecurse/childbranch')],
579
self.my_location_config._get_matching_sections())
581
def test__get_matching_sections_subdir_trailing_slash(self):
568
582
self.get_branch_config('/b')
569
self.assertEqual('/b/', self.my_location_config._get_section())
583
self.assertEqual([('/b/', '')],
584
self.my_location_config._get_matching_sections())
571
def test__get_section_subdir_child(self):
586
def test__get_matching_sections_subdir_child(self):
572
587
self.get_branch_config('/a/foo')
573
self.assertEqual('/a/*', self.my_location_config._get_section())
588
self.assertEqual([('/a/*', ''), ('/a/', 'foo')],
589
self.my_location_config._get_matching_sections())
575
def test__get_section_subdir_child_child(self):
591
def test__get_matching_sections_subdir_child_child(self):
576
592
self.get_branch_config('/a/foo/bar')
577
self.assertEqual('/a/', self.my_location_config._get_section())
593
self.assertEqual([('/a/*', 'bar'), ('/a/', 'foo/bar')],
594
self.my_location_config._get_matching_sections())
579
def test__get_section_trailing_slash_with_children(self):
596
def test__get_matching_sections_trailing_slash_with_children(self):
580
597
self.get_branch_config('/a/')
581
self.assertEqual('/a/', self.my_location_config._get_section())
598
self.assertEqual([('/a/', '')],
599
self.my_location_config._get_matching_sections())
583
def test__get_section_explicit_over_glob(self):
601
def test__get_matching_sections_explicit_over_glob(self):
602
# XXX: 2006-09-08 jamesh
603
# This test only passes because ord('c') > ord('*'). If there
604
# was a config section for '/a/?', it would get precedence
584
606
self.get_branch_config('/a/c')
585
self.assertEqual('/a/c', self.my_location_config._get_section())
607
self.assertEqual([('/a/c', ''), ('/a/*', ''), ('/a/', 'c')],
608
self.my_location_config._get_matching_sections())
588
610
def test_location_without_username(self):
589
self.get_branch_config('http://www.example.com/useglobal')
611
self.get_branch_config('http://www.example.com/ignoreparent')
590
612
self.assertEqual(u'Erik B\u00e5gfors <erik@bagfors.nu>',
591
613
self.my_config.username())