comparison tests/test_utility_commands.py @ 139:89a737852d33

utility_commands: Add tests for url and info. Fix a bad mock in the process.
author Augie Fackler <durin42@gmail.com>
date Thu, 11 Dec 2008 20:24:48 -0600
parents
children 9ffde8662967
comparison
equal deleted inserted replaced
138:40474f6c1f84 139:89a737852d33
1 import urllib # for url quoting
2
3 from mercurial import ui
4 from mercurial import hg
5
6 import utility_commands
7
8 import test_util
9
10 expected_info_output = '''URL: file://%(repo)s/%(branch)s
11 Repository Root: None
12 Repository UUID: df2126f7-00ab-4d49-b42c-7e981dde0bcf
13 Revision: %(rev)s
14 Node Kind: directory
15 Last Changed Author: durin
16 Last Changed Rev: %(rev)s
17 Last Changed Date: %(date)s
18 '''
19
20 class UtilityTests(test_util.TestBase):
21 def test_info_output(self):
22 self._load_fixture_and_fetch('two_heads.svndump')
23 hg.update(self.repo, 'the_branch')
24 u = ui.ui()
25 utility_commands.run_svn_info(u, self.repo, self.wc_path)
26 expected = (expected_info_output %
27 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
28 'repo': urllib.quote(self.repo_path),
29 'branch': 'branches/the_branch',
30 'rev': 5,
31 })
32 self.assertEqual(u.stream.getvalue(), expected)
33 hg.update(self.repo, 'default')
34 u = ui.ui()
35 utility_commands.run_svn_info(u, self.repo, self.wc_path)
36 expected = (expected_info_output %
37 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
38 'repo': urllib.quote(self.repo_path),
39 'branch': 'trunk',
40 'rev': 6,
41 })
42 self.assertEqual(u.stream.getvalue(), expected)
43
44 def test_url_output(self):
45 self._load_fixture_and_fetch('two_revs.svndump')
46 hg.update(self.repo, 'tip')
47 u = ui.ui()
48 utility_commands.print_wc_url(u, self.repo, self.wc_path)
49 expected = 'file://%s\n' % urllib.quote(self.repo_path)
50 self.assertEqual(u.stream.getvalue(), expected)