Mercurial > hgsubversion
annotate svnwrap/tests/test_svnwrap.py @ 165:a05250261102
Fix "hg svn outgoing" help text.
author | Martin Geisler <mg@daimi.au.dk> |
---|---|
date | Tue, 30 Dec 2008 19:24:16 -0600 |
parents | bfbce70a9a57 |
children | 9ad5cf45e30c |
rev | line source |
---|---|
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import os |
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
|
2 import popen2 |
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 |
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
|
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,]) |
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
|
17 proc = popen2.Popen4(['svnadmin', 'load', self.repo_path,]) |
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 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures', |
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
|
19 'project_root_at_repo_root.svndump')) |
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
|
20 proc.tochild.write(inp.read()) |
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
|
21 proc.tochild.close() |
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
|
22 proc.wait() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 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
|
24 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 def tearDown(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 shutil.rmtree(self.tmpdir) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 |
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 def test_num_revs(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 revs = list(self.repo.revisions()) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 tools.eq_(len(revs), 7) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 r = revs[1] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 tools.eq_(r.revnum, 2) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 tools.eq_(sorted(r.paths.keys()), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 ['trunk/alpha', 'trunk/beta', 'trunk/delta']) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 for r in revs: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 for p in r.paths: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 # 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
|
39 if p: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 assert p[0] != '/' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 revs = list(self.repo.revisions(start=3)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 tools.eq_(len(revs), 4) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 |
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 def test_branches(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 |
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 def test_tags(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 tags = self.repo.tags |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 tools.eq_(tags.keys(), ['rev1']) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 tools.eq_(tags['rev1'], ('trunk', 2)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 class TestRootAsSubdirOfRepo(TestBasicRepoLayout): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 def setUp(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 self.repo_path = '%s/testrepo' % self.tmpdir |
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
|
60 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
|
61 self.repo_path,]) |
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
|
62 proc = popen2.Popen4(['svnadmin', 'load', self.repo_path,]) |
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
|
63 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures', |
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')) |
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
|
65 proc.tochild.write(inp.read()) |
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
|
66 proc.tochild.close() |
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
|
67 proc.wait() |
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
|
68 self.repo = svnwrap.SubversionRepo('file://%s/dummyproj' % |
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
|
69 self.repo_path) |