comparison tests/test_fetch_mappings.py @ 576:d96aa92d9ad9

tests: silence test suite by using quiet UIs everywhere
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Fri, 26 Feb 2010 14:50:22 +0100
parents 8e025a6f0db4
children a400f3bf5611
comparison
equal deleted inserted replaced
575:c278a225b750 576:d96aa92d9ad9
2 """ 2 """
3 import os 3 import os
4 import unittest 4 import unittest
5 5
6 from mercurial import commands 6 from mercurial import commands
7 from mercurial import ui
8 from mercurial import node 7 from mercurial import node
9 8
10 import test_util 9 import test_util
11 10
12 from hgsubversion import maps 11 from hgsubversion import maps
28 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 27 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
29 authormap = open(self.authors, 'w') 28 authormap = open(self.authors, 'w')
30 authormap.write('Augie=Augie Fackler <durin42@gmail.com> # stuffy\n') 29 authormap.write('Augie=Augie Fackler <durin42@gmail.com> # stuffy\n')
31 authormap.write("Augie Fackler <durin42@gmail.com>\n") 30 authormap.write("Augie Fackler <durin42@gmail.com>\n")
32 authormap.close() 31 authormap.close()
33 _ui = ui.ui() 32 ui = self.ui(stupid)
34 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) 33 ui.setconfig('hgsubversion', 'authormap', self.authors)
35 _ui.setconfig('hgsubversion', 'authormap', self.authors) 34 commands.clone(ui, test_util.fileurl(self.repo_path),
36 commands.clone(_ui, test_util.fileurl(self.repo_path),
37 self.wc_path, authors=self.authors) 35 self.wc_path, authors=self.authors)
38 self.assertEqual(self.repo[0].user(), 36 self.assertEqual(self.repo[0].user(),
39 'Augie Fackler <durin42@gmail.com>') 37 'Augie Fackler <durin42@gmail.com>')
40 self.assertEqual(self.repo['tip'].user(), 38 self.assertEqual(self.repo['tip'].user(),
41 'evil@5b65bade-98f3-4993-a01f-b7a6710da339') 39 'evil@5b65bade-98f3-4993-a01f-b7a6710da339')
46 def test_author_map_closing_author(self, stupid=False): 44 def test_author_map_closing_author(self, stupid=False):
47 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 45 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
48 authormap = open(self.authors, 'w') 46 authormap = open(self.authors, 'w')
49 authormap.write("evil=Testy <test@test>") 47 authormap.write("evil=Testy <test@test>")
50 authormap.close() 48 authormap.close()
51 _ui = ui.ui() 49 ui = self.ui(stupid)
52 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) 50 ui.setconfig('hgsubversion', 'authormap', self.authors)
53 _ui.setconfig('hgsubversion', 'authormap', self.authors) 51 commands.clone(ui, test_util.fileurl(self.repo_path),
54 commands.clone(_ui, test_util.fileurl(self.repo_path),
55 self.wc_path, authors=self.authors) 52 self.wc_path, authors=self.authors)
56 self.assertEqual(self.repo[0].user(), 53 self.assertEqual(self.repo[0].user(),
57 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339') 54 'Augie@5b65bade-98f3-4993-a01f-b7a6710da339')
58 self.assertEqual(self.repo['tip'].user(), 55 self.assertEqual(self.repo['tip'].user(),
59 'Testy <test@test>') 56 'Testy <test@test>')
65 cwd = os.path.dirname(__file__) 62 cwd = os.path.dirname(__file__)
66 orig = os.path.join(cwd, 'fixtures', 'author-map-test.txt') 63 orig = os.path.join(cwd, 'fixtures', 'author-map-test.txt')
67 new = open(self.authors, 'w') 64 new = open(self.authors, 'w')
68 new.write(open(orig).read()) 65 new.write(open(orig).read())
69 new.close() 66 new.close()
70 test = maps.AuthorMap(ui.ui(), self.authors) 67 test = maps.AuthorMap(self.ui(), self.authors)
71 fromself = set(test) 68 fromself = set(test)
72 test.load(orig) 69 test.load(orig)
73 all = set(test) 70 all = set(test)
74 self.assertEqual(fromself.symmetric_difference(all), set()) 71 self.assertEqual(fromself.symmetric_difference(all), set())
75 72
76 def test_file_map(self, stupid=False): 73 def test_file_map(self, stupid=False):
77 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 74 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
78 filemap = open(self.filemap, 'w') 75 filemap = open(self.filemap, 'w')
79 filemap.write("include alpha\n") 76 filemap.write("include alpha\n")
80 filemap.close() 77 filemap.close()
81 _ui = ui.ui() 78 ui = self.ui(stupid)
82 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) 79 ui.setconfig('hgsubversion', 'filemap', self.filemap)
83 _ui.setconfig('hgsubversion', 'filemap', self.filemap) 80 commands.clone(ui, test_util.fileurl(self.repo_path),
84 commands.clone(_ui, test_util.fileurl(self.repo_path),
85 self.wc_path, filemap=self.filemap) 81 self.wc_path, filemap=self.filemap)
86 self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d') 82 self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d')
87 self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155') 83 self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155')
88 84
89 def test_file_map_stupid(self): 85 def test_file_map_stupid(self):
92 def test_file_map_exclude(self, stupid=False): 88 def test_file_map_exclude(self, stupid=False):
93 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump') 89 test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
94 filemap = open(self.filemap, 'w') 90 filemap = open(self.filemap, 'w')
95 filemap.write("exclude alpha\n") 91 filemap.write("exclude alpha\n")
96 filemap.close() 92 filemap.close()
97 _ui = ui.ui() 93 ui = self.ui(stupid)
98 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) 94 ui.setconfig('hgsubversion', 'filemap', self.filemap)
99 _ui.setconfig('hgsubversion', 'filemap', self.filemap) 95 commands.clone(ui, test_util.fileurl(self.repo_path),
100 commands.clone(_ui, test_util.fileurl(self.repo_path),
101 self.wc_path, filemap=self.filemap) 96 self.wc_path, filemap=self.filemap)
102 self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841') 97 self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841')
103 self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1') 98 self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1')
104 99
105 def test_file_map_exclude_stupid(self): 100 def test_file_map_exclude_stupid(self):
109 test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') 104 test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump')
110 branchmap = open(self.branchmap, 'w') 105 branchmap = open(self.branchmap, 'w')
111 branchmap.write("badname = good-name # stuffy\n") 106 branchmap.write("badname = good-name # stuffy\n")
112 branchmap.write("feature = default\n") 107 branchmap.write("feature = default\n")
113 branchmap.close() 108 branchmap.close()
114 _ui = ui.ui() 109 ui = self.ui(stupid)
115 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) 110 ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
116 _ui.setconfig('hgsubversion', 'branchmap', self.branchmap) 111 commands.clone(ui, test_util.fileurl(self.repo_path),
117 commands.clone(_ui, test_util.fileurl(self.repo_path),
118 self.wc_path, branchmap=self.branchmap) 112 self.wc_path, branchmap=self.branchmap)
119 branches = set(self.repo[i].branch() for i in self.repo) 113 branches = set(self.repo[i].branch() for i in self.repo)
120 self.assert_('badname' not in branches) 114 self.assert_('badname' not in branches)
121 self.assert_('good-name' in branches) 115 self.assert_('good-name' in branches)
122 self.assertEquals(self.repo[2].branch(), 'default') 116 self.assertEquals(self.repo[2].branch(), 'default')