comparison tests/test_utility_commands.py @ 867:50c13e01c7e3

test_util: add a load_and_fetch() returning the repo_path
author Patrick Mezard <patrick@mezard.eu>
date Thu, 19 Apr 2012 18:29:28 +0200
parents 20e73b5ab6f7
children d4312a6f7a87
comparison
equal deleted inserted replaced
866:20e73b5ab6f7 867:50c13e01c7e3
23 Last Changed Author: durin 23 Last Changed Author: durin
24 Last Changed Rev: %(rev)s 24 Last Changed Rev: %(rev)s
25 Last Changed Date: %(date)s 25 Last Changed Date: %(date)s
26 ''' 26 '''
27 27
28 def repourl(repo_path):
29 return util.normalize_url(test_util.fileurl(repo_path))
30
28 class UtilityTests(test_util.TestBase): 31 class UtilityTests(test_util.TestBase):
29 @property
30 def repourl(self):
31 return util.normalize_url(test_util.fileurl(self.repo_path))
32
33 def test_info_output(self): 32 def test_info_output(self):
34 self._load_fixture_and_fetch('two_heads.svndump') 33 repo, repo_path = self.load_and_fetch('two_heads.svndump')
35 hg.update(self.repo, 'the_branch') 34 hg.update(self.repo, 'the_branch')
36 u = self.ui() 35 u = self.ui()
37 u.pushbuffer() 36 u.pushbuffer()
38 svncommands.info(u, self.repo) 37 svncommands.info(u, self.repo)
39 actual = u.popbuffer() 38 actual = u.popbuffer()
40 expected = (expected_info_output % 39 expected = (expected_info_output %
41 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', 40 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
42 'repourl': self.repourl, 41 'repourl': repourl(repo_path),
43 'branch': 'branches/the_branch', 42 'branch': 'branches/the_branch',
44 'rev': 5, 43 'rev': 5,
45 }) 44 })
46 self.assertMultiLineEqual(actual, expected) 45 self.assertMultiLineEqual(actual, expected)
47 hg.update(self.repo, 'default') 46 hg.update(self.repo, 'default')
48 u.pushbuffer() 47 u.pushbuffer()
49 svncommands.info(u, self.repo) 48 svncommands.info(u, self.repo)
50 actual = u.popbuffer() 49 actual = u.popbuffer()
51 expected = (expected_info_output % 50 expected = (expected_info_output %
52 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', 51 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
53 'repourl': self.repourl, 52 'repourl': repourl(repo_path),
54 'branch': 'trunk', 53 'branch': 'trunk',
55 'rev': 6, 54 'rev': 6,
56 }) 55 })
57 self.assertMultiLineEqual(actual, expected) 56 self.assertMultiLineEqual(actual, expected)
58 hg.update(self.repo, 'default') 57 hg.update(self.repo, 'default')
59 u.pushbuffer() 58 u.pushbuffer()
60 svncommands.info(u, self.repo, rev=3) 59 svncommands.info(u, self.repo, rev=3)
61 actual = u.popbuffer() 60 actual = u.popbuffer()
62 expected = (expected_info_output % 61 expected = (expected_info_output %
63 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', 62 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
64 'repourl': self.repourl, 63 'repourl': repourl(repo_path),
65 'branch': 'branches/the_branch', 64 'branch': 'branches/the_branch',
66 'rev': 5, 65 'rev': 5,
67 }) 66 })
68 self.assertMultiLineEqual(actual, expected) 67 self.assertMultiLineEqual(actual, expected)
69 68
70 def test_info_single(self): 69 def test_info_single(self):
71 self._load_fixture_and_fetch('two_heads.svndump', subdir='trunk') 70 repo, repo_path = self.load_and_fetch('two_heads.svndump', subdir='trunk')
72 hg.update(self.repo, 'tip') 71 hg.update(self.repo, 'tip')
73 u = self.ui() 72 u = self.ui()
74 u.pushbuffer() 73 u.pushbuffer()
75 svncommands.info(u, self.repo) 74 svncommands.info(u, self.repo)
76 actual = u.popbuffer() 75 actual = u.popbuffer()
77 expected = (expected_info_output % 76 expected = (expected_info_output %
78 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', 77 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
79 'repourl': self.repourl, 78 'repourl': repourl(repo_path),
80 'branch': 'trunk', 79 'branch': 'trunk',
81 'rev': 6, 80 'rev': 6,
82 }) 81 })
83 self.assertMultiLineEqual(expected, actual) 82 self.assertMultiLineEqual(expected, actual)
84 83
151 wrappers.parents(lambda x, y: None, u, self.repo, svn=True) 150 wrappers.parents(lambda x, y: None, u, self.repo, svn=True)
152 actual = u.popbuffer() 151 actual = u.popbuffer()
153 self.assertEqual(actual, '4:1083037b18d8\n') 152 self.assertEqual(actual, '4:1083037b18d8\n')
154 153
155 def test_outgoing_output(self): 154 def test_outgoing_output(self):
156 self._load_fixture_and_fetch('two_heads.svndump') 155 repo, repo_path = self.load_and_fetch('two_heads.svndump')
157 u = self.ui() 156 u = self.ui()
158 parents = (self.repo['the_branch'].node(), revlog.nullid,) 157 parents = (self.repo['the_branch'].node(), revlog.nullid,)
159 def filectxfn(repo, memctx, path): 158 def filectxfn(repo, memctx, path):
160 return context.memfilectx(path=path, 159 return context.memfilectx(path=path,
161 data='added', 160 data='added',
171 '2008-12-21 16:32:00 -0500', 170 '2008-12-21 16:32:00 -0500',
172 {'branch': 'localbranch', }) 171 {'branch': 'localbranch', })
173 new = self.repo.commitctx(ctx) 172 new = self.repo.commitctx(ctx)
174 hg.update(self.repo, new) 173 hg.update(self.repo, new)
175 u.pushbuffer() 174 u.pushbuffer()
176 commands.outgoing(u, self.repo, self.repourl) 175 commands.outgoing(u, self.repo, repourl(repo_path))
177 actual = u.popbuffer() 176 actual = u.popbuffer()
178 self.assertTrue(node.hex(self.repo['localbranch'].node())[:8] in actual) 177 self.assertTrue(node.hex(self.repo['localbranch'].node())[:8] in actual)
179 self.assertEqual(actual.strip(), '5:6de15430fa20') 178 self.assertEqual(actual.strip(), '5:6de15430fa20')
180 hg.update(self.repo, 'default') 179 hg.update(self.repo, 'default')
181 u.pushbuffer() 180 u.pushbuffer()
182 commands.outgoing(u, self.repo, self.repourl) 181 commands.outgoing(u, self.repo, repourl(repo_path))
183 actual = u.popbuffer() 182 actual = u.popbuffer()
184 self.assertEqual(actual, '') 183 self.assertEqual(actual, '')
185 184
186 def test_rebase(self): 185 def test_rebase(self):
187 self._load_fixture_and_fetch('two_revs.svndump') 186 self._load_fixture_and_fetch('two_revs.svndump')