Mercurial > treepkg
comparison test/test_git.py @ 509:c4288095887f
update git tag detector and add test
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Tue, 09 Nov 2010 14:54:55 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
508:29f6d1f5cc53 | 509:c4288095887f |
---|---|
1 # Copyright (C) 2010 by Intevation GmbH | |
2 # Authors: | |
3 # Bjoern Ricks <bjoern.ricks@intevation.de> | |
4 # | |
5 # This program is free software under the GPL (>=v2) | |
6 # Read the file COPYING coming with the software for details. | |
7 | |
8 """Tests for the treepkg.git module""" | |
9 | |
10 | |
11 import unittest | |
12 import os | |
13 | |
14 import treepkg.run as run | |
15 from treepkg.cmdexpand import cmdexpand | |
16 from filesupport import FileTestMixin | |
17 | |
18 import treepkg.git as git | |
19 | |
20 class TestTagDetector(unittest.TestCase, FileTestMixin): | |
21 | |
22 def test_tag(self): | |
23 dirname = self.create_test_specific_temp_dir() | |
24 repodir = self.create_temp_dir("repo") | |
25 clonedir = os.path.join(dirname, "clone") | |
26 run.call(cmdexpand("git init -q"), cwd=repodir) | |
27 | |
28 file = open(os.path.join(repodir, "tmp"), "w") | |
29 file.write("test") | |
30 file.close() | |
31 | |
32 run.call(cmdexpand("git add tmp"), cwd=repodir) | |
33 run.call(cmdexpand("git commit -m \"Add tmp file\""), cwd=repodir) | |
34 run.call(cmdexpand("git tag tag1"), cwd=repodir) | |
35 run.call(cmdexpand("git tag tag2"), cwd=repodir) | |
36 run.call(cmdexpand("git tag anothertag"), cwd=repodir) | |
37 | |
38 tagdetector1 = git.TagDetector(repodir, "tag*", clonedir) | |
39 tags = tagdetector1.list_tags() | |
40 urlrev = tagdetector1.newest_tag_revision() | |
41 | |
42 self.assertEquals(len(tags), 2) | |
43 self.assertEquals(urlrev[0], "tag2") | |
44 | |
45 tagdetector2 = git.TagDetector(dirname, "*tag*", clonedir) | |
46 tags = tagdetector2.list_tags() | |
47 urlrev = tagdetector2.newest_tag_revision() | |
48 | |
49 self.assertEquals(len(tags), 3) | |
50 self.assertEquals(urlrev[0], "tag2") | |
51 | |
52 tagdetector3 = git.TagDetector(dirname, "another*", clonedir) | |
53 tags = tagdetector3.list_tags() | |
54 urlrev = tagdetector3.newest_tag_revision() | |
55 | |
56 self.assertEquals(len(tags), 1) | |
57 self.assertEquals(urlrev[0], "anothertag") |