comparison tests/test_utility_commands.py @ 253:c3d5c4ae9c7c

Work with simple command table instead of decorators.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Fri, 10 Apr 2009 23:09:59 +0200
parents 4950b18cf949
children 7932d098cb5f
comparison
equal deleted inserted replaced
252:4d3bcd2f26ed 253:c3d5c4ae9c7c
24 class UtilityTests(test_util.TestBase): 24 class UtilityTests(test_util.TestBase):
25 def test_info_output(self): 25 def test_info_output(self):
26 self._load_fixture_and_fetch('two_heads.svndump') 26 self._load_fixture_and_fetch('two_heads.svndump')
27 hg.update(self.repo, 'the_branch') 27 hg.update(self.repo, 'the_branch')
28 u = ui.ui() 28 u = ui.ui()
29 utility_commands.run_svn_info(u, self.repo, self.wc_path) 29 utility_commands.info(u, self.repo, self.wc_path)
30 expected = (expected_info_output % 30 expected = (expected_info_output %
31 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', 31 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
32 'repourl': test_util.fileurl(self.repo_path), 32 'repourl': test_util.fileurl(self.repo_path),
33 'branch': 'branches/the_branch', 33 'branch': 'branches/the_branch',
34 'rev': 5, 34 'rev': 5,
35 }) 35 })
36 self.assertEqual(u.stream.getvalue(), expected) 36 self.assertEqual(u.stream.getvalue(), expected)
37 hg.update(self.repo, 'default') 37 hg.update(self.repo, 'default')
38 u = ui.ui() 38 u = ui.ui()
39 utility_commands.run_svn_info(u, self.repo, self.wc_path) 39 utility_commands.info(u, self.repo, self.wc_path)
40 expected = (expected_info_output % 40 expected = (expected_info_output %
41 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', 41 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
42 'repourl': test_util.fileurl(self.repo_path), 42 'repourl': test_util.fileurl(self.repo_path),
43 'branch': 'trunk', 43 'branch': 'trunk',
44 'rev': 6, 44 'rev': 6,
63 'testy', 63 'testy',
64 '2008-12-21 16:32:00 -0500', 64 '2008-12-21 16:32:00 -0500',
65 {'branch': 'localbranch', }) 65 {'branch': 'localbranch', })
66 new = self.repo.commitctx(ctx) 66 new = self.repo.commitctx(ctx)
67 hg.update(self.repo, new) 67 hg.update(self.repo, new)
68 utility_commands.print_parent_revision(u, self.repo, self.wc_path) 68 utility_commands.parent(u, self.repo, self.wc_path)
69 self.assert_(node.hex(self.repo['the_branch'].node())[:8] in 69 self.assert_(node.hex(self.repo['the_branch'].node())[:8] in
70 u.stream.getvalue()) 70 u.stream.getvalue())
71 self.assert_('the_branch' in u.stream.getvalue()) 71 self.assert_('the_branch' in u.stream.getvalue())
72 self.assert_('r5' in u.stream.getvalue()) 72 self.assert_('r5' in u.stream.getvalue())
73 hg.update(self.repo, 'default') 73 hg.update(self.repo, 'default')
74 u = ui.ui() 74 u = ui.ui()
75 utility_commands.print_parent_revision(u, self.repo, self.wc_path) 75 utility_commands.parent(u, self.repo, self.wc_path)
76 self.assert_(node.hex(self.repo['default'].node())[:8] in 76 self.assert_(node.hex(self.repo['default'].node())[:8] in
77 u.stream.getvalue()) 77 u.stream.getvalue())
78 self.assert_('trunk' in u.stream.getvalue()) 78 self.assert_('trunk' in u.stream.getvalue())
79 self.assert_('r6' in u.stream.getvalue()) 79 self.assert_('r6' in u.stream.getvalue())
80 80
96 'testy', 96 'testy',
97 '2008-12-21 16:32:00 -0500', 97 '2008-12-21 16:32:00 -0500',
98 {'branch': 'localbranch', }) 98 {'branch': 'localbranch', })
99 new = self.repo.commitctx(ctx) 99 new = self.repo.commitctx(ctx)
100 hg.update(self.repo, new) 100 hg.update(self.repo, new)
101 utility_commands.show_outgoing_to_svn(u, self.repo, self.wc_path) 101 utility_commands.outgoing(u, self.repo, self.wc_path)
102 self.assert_(node.hex(self.repo['localbranch'].node())[:8] in 102 self.assert_(node.hex(self.repo['localbranch'].node())[:8] in
103 u.stream.getvalue()) 103 u.stream.getvalue())
104 self.assert_('testy' in u.stream.getvalue()) 104 self.assert_('testy' in u.stream.getvalue())
105 hg.update(self.repo, 'default') 105 hg.update(self.repo, 'default')
106 u = ui.ui() 106 u = ui.ui()
107 utility_commands.show_outgoing_to_svn(u, self.repo, self.wc_path) 107 utility_commands.outgoing(u, self.repo, self.wc_path)
108 self.assertEqual(u.stream.getvalue(), 'No outgoing changes found.\n') 108 self.assertEqual(u.stream.getvalue(), 'No outgoing changes found.\n')
109 109
110 def test_url_output(self): 110 def test_url_output(self):
111 self._load_fixture_and_fetch('two_revs.svndump') 111 self._load_fixture_and_fetch('two_revs.svndump')
112 hg.update(self.repo, 'tip') 112 hg.update(self.repo, 'tip')
113 u = ui.ui() 113 u = ui.ui()
114 utility_commands.print_wc_url(u, self.repo, self.wc_path) 114 utility_commands.url(u, self.repo, self.wc_path)
115 expected = test_util.fileurl(self.repo_path) + '\n' 115 expected = test_util.fileurl(self.repo_path) + '\n'
116 self.assertEqual(u.stream.getvalue(), expected) 116 self.assertEqual(u.stream.getvalue(), expected)
117 117
118 def test_rebase(self): 118 def test_rebase(self):
119 self._load_fixture_and_fetch('two_revs.svndump') 119 self._load_fixture_and_fetch('two_revs.svndump')
134 {'branch': 'localbranch', }) 134 {'branch': 'localbranch', })
135 self.repo.commitctx(ctx) 135 self.repo.commitctx(ctx)
136 self.assertEqual(self.repo['tip'].branch(), 'localbranch') 136 self.assertEqual(self.repo['tip'].branch(), 'localbranch')
137 beforerebasehash = self.repo['tip'].node() 137 beforerebasehash = self.repo['tip'].node()
138 hg.update(self.repo, 'tip') 138 hg.update(self.repo, 'tip')
139 utility_commands.rebase_commits(ui.ui(), self.repo) 139 utility_commands.rebase(ui.ui(), self.repo)
140 self.assertEqual(self.repo['tip'].branch(), 'localbranch') 140 self.assertEqual(self.repo['tip'].branch(), 'localbranch')
141 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0]) 141 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0])
142 self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) 142 self.assertNotEqual(beforerebasehash, self.repo['tip'].node())
143 143
144 def test_url_is_normalized(self): 144 def test_url_is_normalized(self):
148 svncommands.pull(ui.ui(), 148 svncommands.pull(ui.ui(),
149 svn_url=test_util.fileurl(self.repo_path) + '/', 149 svn_url=test_util.fileurl(self.repo_path) + '/',
150 hg_repo_path=self.wc_path, stupid=False) 150 hg_repo_path=self.wc_path, stupid=False)
151 hg.update(self.repo, 'tip') 151 hg.update(self.repo, 'tip')
152 u = ui.ui() 152 u = ui.ui()
153 utility_commands.print_wc_url(u, self.repo, self.wc_path) 153 utility_commands.url(u, self.repo, self.wc_path)
154 expected = test_util.fileurl(self.repo_path) + '\n' 154 expected = test_util.fileurl(self.repo_path) + '\n'
155 self.assertEqual(u.stream.getvalue(), expected) 155 self.assertEqual(u.stream.getvalue(), expected)
156 156
157 def test_genignore(self): 157 def test_genignore(self):
158 """Verify url gets normalized on initial clone. 158 """Verify url gets normalized on initial clone.
161 svncommands.pull(ui.ui(), 161 svncommands.pull(ui.ui(),
162 svn_url=test_util.fileurl(self.repo_path) + '/', 162 svn_url=test_util.fileurl(self.repo_path) + '/',
163 hg_repo_path=self.wc_path, stupid=False) 163 hg_repo_path=self.wc_path, stupid=False)
164 hg.update(self.repo, 'tip') 164 hg.update(self.repo, 'tip')
165 u = ui.ui() 165 u = ui.ui()
166 utility_commands.generate_ignore(u, self.repo, self.wc_path) 166 utility_commands.genignore(u, self.repo, self.wc_path)
167 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), 167 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(),
168 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') 168 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n')
169 169
170 def test_list_authors(self): 170 def test_list_authors(self):
171 test_util.load_svndump_fixture(self.repo_path, 171 test_util.load_svndump_fixture(self.repo_path,
172 'replace_trunk_with_branch.svndump') 172 'replace_trunk_with_branch.svndump')
173 u = ui.ui() 173 u = ui.ui()
174 utility_commands.list_authors(u, 174 utility_commands.listauthors(u,
175 args=[test_util.fileurl(self.repo_path)], 175 args=[test_util.fileurl(self.repo_path)],
176 authors=None) 176 authors=None)
177 self.assertEqual(u.stream.getvalue(), 'Augie\nevil\n') 177 self.assertEqual(u.stream.getvalue(), 'Augie\nevil\n')
178 178
179 179
180 def test_list_authors_map(self): 180 def test_list_authors_map(self):
181 test_util.load_svndump_fixture(self.repo_path, 181 test_util.load_svndump_fixture(self.repo_path,
182 'replace_trunk_with_branch.svndump') 182 'replace_trunk_with_branch.svndump')
183 author_path = os.path.join(self.repo_path, 'authors') 183 author_path = os.path.join(self.repo_path, 'authors')
184 utility_commands.list_authors(ui.ui(), 184 utility_commands.listauthors(ui.ui(),
185 args=[test_util.fileurl(self.repo_path)], 185 args=[test_util.fileurl(self.repo_path)],
186 authors=author_path) 186 authors=author_path)
187 self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n') 187 self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n')
188 188
189 189
190 def suite(): 190 def suite():
191 all = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests), 191 all = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests),