comparison tests/test_fetch_command.py @ 16:48a44546c12f

Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests. Also added some tests for pushing.
author Augie Fackler <durin42@gmail.com>
date Tue, 07 Oct 2008 22:13:14 -0500
parents db32dee803a8
children f4c751037a4a
comparison
equal deleted inserted replaced
15:db32dee803a8 16:48a44546c12f
6 from mercurial import hg 6 from mercurial import hg
7 from mercurial import ui 7 from mercurial import ui
8 from mercurial import node 8 from mercurial import node
9 9
10 import fetch_command 10 import fetch_command
11 import util 11 import test_util
12 12
13 class TestBasicRepoLayout(unittest.TestCase): 13 class TestBasicRepoLayout(unittest.TestCase):
14 def setUp(self): 14 def setUp(self):
15 self.oldwd = os.getcwd() 15 self.oldwd = os.getcwd()
16 self.tmpdir = tempfile.mkdtemp('svnwrap_test') 16 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
20 def tearDown(self): 20 def tearDown(self):
21 shutil.rmtree(self.tmpdir) 21 shutil.rmtree(self.tmpdir)
22 os.chdir(self.oldwd) 22 os.chdir(self.oldwd)
23 23
24 def test_fresh_fetch_single_rev(self): 24 def test_fresh_fetch_single_rev(self):
25 util.load_svndump_fixture(self.repo_path, 'single_rev.svndump') 25 test_util.load_svndump_fixture(self.repo_path, 'single_rev.svndump')
26 fetch_command.fetch_revisions(ui.ui(), 26 fetch_command.fetch_revisions(ui.ui(),
27 svn_url='file://%s' % self.repo_path, 27 svn_url='file://%s' % self.repo_path,
28 hg_repo_path=self.wc_path) 28 hg_repo_path=self.wc_path)
29 repo = hg.repository(ui.ui(), self.wc_path) 29 repo = hg.repository(ui.ui(), self.wc_path)
30 self.assertEqual(node.hex(repo['tip'].node()), 30 self.assertEqual(node.hex(repo['tip'].node()),
31 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') 31 'a47d0ce778660a91c31bf2c21c448e9ee296ac90')
32 self.assertEqual(repo['tip'], repo[0]) 32 self.assertEqual(repo['tip'], repo[0])
33 33
34 def test_fresh_fetch_two_revs(self): 34 def test_fresh_fetch_two_revs(self):
35 util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') 35 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump')
36 fetch_command.fetch_revisions(ui.ui(), 36 fetch_command.fetch_revisions(ui.ui(),
37 svn_url='file://%s' % self.repo_path, 37 svn_url='file://%s' % self.repo_path,
38 hg_repo_path=self.wc_path) 38 hg_repo_path=self.wc_path)
39 repo = hg.repository(ui.ui(), self.wc_path) 39 repo = hg.repository(ui.ui(), self.wc_path)
40 # TODO there must be a better way than repo[0] for this check 40 # TODO there must be a better way than repo[0] for this check
43 self.assertEqual(node.hex(repo['tip'].node()), 43 self.assertEqual(node.hex(repo['tip'].node()),
44 'bf3767835b3b32ecc775a298c2fa27134dd91c11') 44 'bf3767835b3b32ecc775a298c2fa27134dd91c11')
45 self.assertEqual(repo['tip'], repo[1]) 45 self.assertEqual(repo['tip'], repo[1])
46 46
47 def test_branches(self): 47 def test_branches(self):
48 util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') 48 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump')
49 fetch_command.fetch_revisions(ui.ui(), 49 fetch_command.fetch_revisions(ui.ui(),
50 svn_url='file://%s' % self.repo_path, 50 svn_url='file://%s' % self.repo_path,
51 hg_repo_path=self.wc_path) 51 hg_repo_path=self.wc_path)
52 repo = hg.repository(ui.ui(), self.wc_path) 52 repo = hg.repository(ui.ui(), self.wc_path)
53 # TODO there must be a better way than repo[0] for this check 53 # TODO there must be a better way than repo[0] for this check
58 self.assertEqual(len(repo['tip'].parents()), 1) 58 self.assertEqual(len(repo['tip'].parents()), 1)
59 self.assertEqual(repo['tip'].parents()[0], repo['default']) 59 self.assertEqual(repo['tip'].parents()[0], repo['default'])
60 self.assertEqual(len(repo.heads()), 1) 60 self.assertEqual(len(repo.heads()), 1)
61 61
62 def test_two_branches_with_heads(self): 62 def test_two_branches_with_heads(self):
63 util.load_svndump_fixture(self.repo_path, 'two_heads.svndump') 63 test_util.load_svndump_fixture(self.repo_path, 'two_heads.svndump')
64 fetch_command.fetch_revisions(ui.ui(), 64 fetch_command.fetch_revisions(ui.ui(),
65 svn_url='file://%s' % self.repo_path, 65 svn_url='file://%s' % self.repo_path,
66 hg_repo_path=self.wc_path) 66 hg_repo_path=self.wc_path)
67 repo = hg.repository(ui.ui(), self.wc_path) 67 repo = hg.repository(ui.ui(), self.wc_path)
68 # TODO there must be a better way than repo[0] for this check 68 # TODO there must be a better way than repo[0] for this check
75 self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()), 75 self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()),
76 '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') 76 '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e')
77 self.assertEqual(len(repo['tip'].parents()), 1) 77 self.assertEqual(len(repo['tip'].parents()), 1)
78 self.assertEqual(repo['tip'], repo['default']) 78 self.assertEqual(repo['tip'], repo['default'])
79 self.assertEqual(len(repo.heads()), 2) 79 self.assertEqual(len(repo.heads()), 2)
80
81 def suite():
82 return unittest.TestLoader().loadTestsFromTestCase(TestBasicRepoLayout)