comparison tests/test_svnwrap.py @ 347:537de0300510

Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 22 May 2009 15:12:31 +0200
parents
children 37304494cd15
comparison
equal deleted inserted replaced
346:4b992ebdecc6 347:537de0300510
1 import imp
2 import os
3 import subprocess
4 import shutil
5 import tempfile
6 import unittest
7
8 import test_util
9
10 from hgsubversion import svnwrap
11
12 class TestBasicRepoLayout(unittest.TestCase):
13 def setUp(self):
14 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
15 self.repo_path = '%s/testrepo' % self.tmpdir
16 os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create',
17 self.repo_path,])
18 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures',
19 'project_root_at_repo_root.svndump'))
20 proc = subprocess.call(['svnadmin', 'load', self.repo_path,],
21 stdin=inp, close_fds=True,
22 stdout=subprocess.PIPE,
23 stderr=subprocess.STDOUT)
24 assert proc == 0
25 self.repo = svnwrap.SubversionRepo('file://%s' % self.repo_path)
26
27 def tearDown(self):
28 shutil.rmtree(self.tmpdir)
29
30
31 def test_num_revs(self):
32 revs = list(self.repo.revisions())
33 self.assertEqual(len(revs), 7)
34 r = revs[1]
35 self.assertEqual(r.revnum, 2)
36 self.assertEqual(sorted(r.paths.keys()),
37 ['trunk/alpha', 'trunk/beta', 'trunk/delta'])
38 for r in revs:
39 for p in r.paths:
40 # make sure these paths are always non-absolute for sanity
41 if p:
42 assert p[0] != '/'
43 revs = list(self.repo.revisions(start=3))
44 self.assertEqual(len(revs), 4)
45
46
47 def test_branches(self):
48 self.assertEqual(self.repo.branches.keys(), ['crazy', 'more_crazy'])
49 self.assertEqual(self.repo.branches['crazy'], ('trunk', 2, 4))
50 self.assertEqual(self.repo.branches['more_crazy'], ('trunk', 5, 7))
51
52
53 def test_tags(self):
54 tags = self.repo.tags
55 self.assertEqual(tags.keys(), ['rev1'])
56 self.assertEqual(tags['rev1'], ('trunk', 2))
57
58 class TestRootAsSubdirOfRepo(TestBasicRepoLayout):
59 def setUp(self):
60 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
61 self.repo_path = '%s/testrepo' % self.tmpdir
62 os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create',
63 self.repo_path,])
64 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures',
65 'project_root_not_repo_root.svndump'))
66 ret = subprocess.call(['svnadmin', 'load', self.repo_path,],
67 stdin=inp, close_fds=True,
68 stdout=subprocess.PIPE,
69 stderr=subprocess.STDOUT)
70 assert ret == 0
71 self.repo = svnwrap.SubversionRepo('file://%s/dummyproj' %
72 self.repo_path)
73 def suite():
74 all = [unittest.TestLoader().loadTestsFromTestCase(TestBasicRepoLayout),
75 unittest.TestLoader().loadTestsFromTestCase(TestRootAsSubdirOfRepo)]
76 return unittest.TestSuite(all)