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