annotate test/test_git.py @ 542:dc17b62d3cdd

contrib: Added copy-latest-pkgs.py to copy/hardlink latest packages from the mill to the next higher attention level.
author Sascha Teichmann <teichmann@intevation.de>
date Tue, 11 Jan 2011 17:20:02 +0000
parents c4288095887f
children
rev   line source
509
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
1 # Copyright (C) 2010 by Intevation GmbH
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
2 # Authors:
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
3 # Bjoern Ricks <bjoern.ricks@intevation.de>
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
4 #
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
5 # This program is free software under the GPL (>=v2)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
6 # Read the file COPYING coming with the software for details.
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
7
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
8 """Tests for the treepkg.git module"""
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
9
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
10
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
11 import unittest
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
12 import os
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
13
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
14 import treepkg.run as run
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
15 from treepkg.cmdexpand import cmdexpand
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
16 from filesupport import FileTestMixin
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
17
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
18 import treepkg.git as git
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
19
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
20 class TestTagDetector(unittest.TestCase, FileTestMixin):
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
21
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
22 def test_tag(self):
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
23 dirname = self.create_test_specific_temp_dir()
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
24 repodir = self.create_temp_dir("repo")
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
25 clonedir = os.path.join(dirname, "clone")
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
26 run.call(cmdexpand("git init -q"), cwd=repodir)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
27
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
28 file = open(os.path.join(repodir, "tmp"), "w")
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
29 file.write("test")
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
30 file.close()
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
31
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
32 run.call(cmdexpand("git add tmp"), cwd=repodir)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
33 run.call(cmdexpand("git commit -m \"Add tmp file\""), cwd=repodir)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
34 run.call(cmdexpand("git tag tag1"), cwd=repodir)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
35 run.call(cmdexpand("git tag tag2"), cwd=repodir)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
36 run.call(cmdexpand("git tag anothertag"), cwd=repodir)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
37
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
38 tagdetector1 = git.TagDetector(repodir, "tag*", clonedir)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
39 tags = tagdetector1.list_tags()
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
40 urlrev = tagdetector1.newest_tag_revision()
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
41
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
42 self.assertEquals(len(tags), 2)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
43 self.assertEquals(urlrev[0], "tag2")
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
44
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
45 tagdetector2 = git.TagDetector(dirname, "*tag*", clonedir)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
46 tags = tagdetector2.list_tags()
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
47 urlrev = tagdetector2.newest_tag_revision()
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
48
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
49 self.assertEquals(len(tags), 3)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
50 self.assertEquals(urlrev[0], "tag2")
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
51
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
52 tagdetector3 = git.TagDetector(dirname, "another*", clonedir)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
53 tags = tagdetector3.list_tags()
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
54 urlrev = tagdetector3.newest_tag_revision()
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
55
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
56 self.assertEquals(len(tags), 1)
c4288095887f update git tag detector and add test
Bjoern Ricks <bricks@intevation.de>
parents:
diff changeset
57 self.assertEquals(urlrev[0], "anothertag")
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)