Mercurial > hgsubversion
comparison tests/test_push_command.py @ 82:71de43e9f614
Extract PushTest common code into test_util.TestBase
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 14 Nov 2008 16:18:24 -0600 |
parents | 83179a183927 |
children | 6c9b7cf1c5aa |
comparison
equal
deleted
inserted
replaced
81:85dcea81f22b | 82:71de43e9f614 |
---|---|
15 import push_cmd | 15 import push_cmd |
16 import test_util | 16 import test_util |
17 import time | 17 import time |
18 | 18 |
19 | 19 |
20 class PushOverSvnserveTests(unittest.TestCase): | 20 class PushOverSvnserveTests(test_util.TestBase): |
21 def setUp(self): | 21 def setUp(self): |
22 self.oldwd = os.getcwd() | 22 test_util.TestBase.setUp(self) |
23 self.tmpdir = tempfile.mkdtemp('svnwrap_test') | |
24 self.repo_path = '%s/testrepo' % self.tmpdir | |
25 self.wc_path = '%s/testrepo_wc' % self.tmpdir | |
26 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') | 23 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') |
27 open(os.path.join(self.repo_path, 'conf', 'svnserve.conf'), | 24 open(os.path.join(self.repo_path, 'conf', 'svnserve.conf'), |
28 'w').write('[general]\nanon-access=write\n[sasl]\n') | 25 'w').write('[general]\nanon-access=write\n[sasl]\n') |
29 # Paranoia: we try and connect to localhost on 3689 before we start | 26 # Paranoia: we try and connect to localhost on 3689 before we start |
30 # svnserve. If it is running, we force the test to fail early. | 27 # svnserve. If it is running, we force the test to fail early. |
46 fetch_command.fetch_revisions(ui.ui(), | 43 fetch_command.fetch_revisions(ui.ui(), |
47 svn_url='svn://localhost/', | 44 svn_url='svn://localhost/', |
48 hg_repo_path=self.wc_path) | 45 hg_repo_path=self.wc_path) |
49 | 46 |
50 def tearDown(self): | 47 def tearDown(self): |
51 test_util.rmtree(self.tmpdir) | |
52 os.chdir(self.oldwd) | |
53 os.system('kill -9 %d' % self.svnserve_pid) | 48 os.system('kill -9 %d' % self.svnserve_pid) |
54 | 49 test_util.TestBase.tearDown(self) |
55 # define this as a property so that it reloads anytime we need it | |
56 @property | |
57 def repo(self): | |
58 return hg.repository(ui.ui(), self.wc_path) | |
59 | 50 |
60 def test_push_to_default(self, commit=True): | 51 def test_push_to_default(self, commit=True): |
61 repo = self.repo | 52 repo = self.repo |
62 old_tip = repo['tip'].node() | 53 old_tip = repo['tip'].node() |
63 expected_parent = repo['default'].node() | 54 expected_parent = repo['default'].node() |
89 self.assertEqual(tip.parents()[0].node(), expected_parent) | 80 self.assertEqual(tip.parents()[0].node(), expected_parent) |
90 self.assertEqual(tip['adding_file'].data(), 'foo') | 81 self.assertEqual(tip['adding_file'].data(), 'foo') |
91 self.assertEqual(tip.branch(), 'default') | 82 self.assertEqual(tip.branch(), 'default') |
92 | 83 |
93 | 84 |
94 class PushTests(unittest.TestCase): | 85 class PushTests(test_util.TestBase): |
95 def setUp(self): | 86 def setUp(self): |
96 self.oldwd = os.getcwd() | 87 test_util.TestBase.setUp(self) |
97 self.tmpdir = tempfile.mkdtemp('svnwrap_test') | |
98 self.repo_path = '%s/testrepo' % self.tmpdir | |
99 self.wc_path = '%s/testrepo_wc' % self.tmpdir | |
100 test_util.load_fixture_and_fetch('simple_branch.svndump', | 88 test_util.load_fixture_and_fetch('simple_branch.svndump', |
101 self.repo_path, | 89 self.repo_path, |
102 self.wc_path) | 90 self.wc_path) |
103 | |
104 # define this as a property so that it reloads anytime we need it | |
105 @property | |
106 def repo(self): | |
107 return hg.repository(ui.ui(), self.wc_path) | |
108 | |
109 def pushrevisions(self): | |
110 push_cmd.push_revisions_to_subversion( | |
111 ui.ui(), repo=self.repo, hg_repo_path=self.wc_path, | |
112 svn_url=test_util.fileurl(self.repo_path)) | |
113 | |
114 def tearDown(self): | |
115 test_util.rmtree(self.tmpdir) | |
116 os.chdir(self.oldwd) | |
117 | 91 |
118 def test_push_to_default(self, commit=True): | 92 def test_push_to_default(self, commit=True): |
119 repo = self.repo | 93 repo = self.repo |
120 old_tip = repo['tip'].node() | 94 old_tip = repo['tip'].node() |
121 expected_parent = repo['default'].node() | 95 expected_parent = repo['default'].node() |