Mercurial > hgsubversion
annotate svnwrap/tests/test_svnwrap.py @ 325:4f4db3d2fdbb
2.4 compat fixes.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 18 May 2009 17:09:26 -0500 |
parents | 9ad5cf45e30c |
children |
rev | line source |
---|---|
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import os |
309
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
2 import subprocess |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import shutil |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import tempfile |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 import unittest |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 from nose import tools |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 import svnwrap |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 class TestBasicRepoLayout(unittest.TestCase): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 def setUp(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 self.repo_path = '%s/testrepo' % self.tmpdir |
325 | 15 os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create', |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 self.repo_path,]) |
325 | 17 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures', |
26
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
18 'project_root_at_repo_root.svndump')) |
325 | 19 proc = subprocess.call(['svnadmin', 'load', self.repo_path,], |
309
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
20 stdin=inp, close_fds=True, |
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
21 stdout=subprocess.PIPE, |
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
22 stderr=subprocess.STDOUT) |
325 | 23 assert proc == 0 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 self.repo = svnwrap.SubversionRepo('file://%s' % self.repo_path) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 def tearDown(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 shutil.rmtree(self.tmpdir) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 def test_num_revs(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 revs = list(self.repo.revisions()) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 tools.eq_(len(revs), 7) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 r = revs[1] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 tools.eq_(r.revnum, 2) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 tools.eq_(sorted(r.paths.keys()), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 ['trunk/alpha', 'trunk/beta', 'trunk/delta']) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 for r in revs: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 for p in r.paths: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 # make sure these paths are always non-absolute for sanity |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 if p: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 assert p[0] != '/' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 revs = list(self.repo.revisions(start=3)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 tools.eq_(len(revs), 4) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 def test_branches(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 tools.eq_(self.repo.branches.keys(), ['crazy', 'more_crazy']) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 tools.eq_(self.repo.branches['crazy'], ('trunk', 2, 4)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 tools.eq_(self.repo.branches['more_crazy'], ('trunk', 5, 7)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 def test_tags(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 tags = self.repo.tags |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 tools.eq_(tags.keys(), ['rev1']) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 tools.eq_(tags['rev1'], ('trunk', 2)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 class TestRootAsSubdirOfRepo(TestBasicRepoLayout): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 def setUp(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 self.repo_path = '%s/testrepo' % self.tmpdir |
325 | 61 os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create', |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
62 self.repo_path,]) |
325 | 63 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures', |
26
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
64 'project_root_not_repo_root.svndump')) |
325 | 65 ret = subprocess.call(['svnadmin', 'load', self.repo_path,], |
309
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
66 stdin=inp, close_fds=True, |
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
67 stdout=subprocess.PIPE, |
9ad5cf45e30c
svnwrap/tests: use the subprocess module rather than the popen module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
26
diff
changeset
|
68 stderr=subprocess.STDOUT) |
325 | 69 assert ret == 0 |
70 self.repo = svnwrap.SubversionRepo('file://%s/dummyproj' % | |
26
bfbce70a9a57
Reworked the svnwrap tests to use the same fixture system as I created for the hgsubversion tests since it is much much faster.
Augie Fackler <durin42@gmail.com>
parents:
7
diff
changeset
|
71 self.repo_path) |