annotate tests/test_utility_commands.py @ 140:9ffde8662967

util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
author Augie Fackler <durin42@gmail.com>
date Thu, 11 Dec 2008 20:41:57 -0600
parents 89a737852d33
children 04800fda7af5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
7 import fetch_command
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
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)
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
51
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
52 def test_url_is_normalized(self):
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
53 """Verify url gets normalized on initial clone.
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
54 """
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
55 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump')
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
56 fetch_command.fetch_revisions(ui.ui(),
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
57 svn_url=test_util.fileurl(self.repo_path)+'/',
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
58 hg_repo_path=self.wc_path,
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
59 stupid=False)
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
60 hg.update(self.repo, 'tip')
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
61 u = ui.ui()
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
62 utility_commands.print_wc_url(u, self.repo, self.wc_path)
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
63 expected = 'file://%s\n' % urllib.quote(self.repo_path)
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 139
diff changeset
64 self.assertEqual(u.stream.getvalue(), expected)