bricks@509: # Copyright (C) 2010 by Intevation GmbH bricks@509: # Authors: bricks@509: # Bjoern Ricks bricks@509: # bricks@509: # This program is free software under the GPL (>=v2) bricks@509: # Read the file COPYING coming with the software for details. bricks@509: bricks@509: """Tests for the treepkg.git module""" bricks@509: bricks@509: bricks@509: import unittest bricks@509: import os bricks@509: bricks@509: import treepkg.run as run bricks@509: from treepkg.cmdexpand import cmdexpand bricks@509: from filesupport import FileTestMixin bricks@509: bricks@509: import treepkg.git as git bricks@509: bricks@509: class TestTagDetector(unittest.TestCase, FileTestMixin): bricks@509: bricks@509: def test_tag(self): bricks@509: dirname = self.create_test_specific_temp_dir() bricks@509: repodir = self.create_temp_dir("repo") bricks@509: clonedir = os.path.join(dirname, "clone") bricks@509: run.call(cmdexpand("git init -q"), cwd=repodir) bricks@509: bricks@509: file = open(os.path.join(repodir, "tmp"), "w") bricks@509: file.write("test") bricks@509: file.close() bricks@509: bricks@509: run.call(cmdexpand("git add tmp"), cwd=repodir) bricks@509: run.call(cmdexpand("git commit -m \"Add tmp file\""), cwd=repodir) bricks@509: run.call(cmdexpand("git tag tag1"), cwd=repodir) bricks@509: run.call(cmdexpand("git tag tag2"), cwd=repodir) bricks@509: run.call(cmdexpand("git tag anothertag"), cwd=repodir) bricks@509: bricks@509: tagdetector1 = git.TagDetector(repodir, "tag*", clonedir) bricks@509: tags = tagdetector1.list_tags() bricks@509: urlrev = tagdetector1.newest_tag_revision() bricks@509: bricks@509: self.assertEquals(len(tags), 2) bricks@509: self.assertEquals(urlrev[0], "tag2") bricks@509: bricks@509: tagdetector2 = git.TagDetector(dirname, "*tag*", clonedir) bricks@509: tags = tagdetector2.list_tags() bricks@509: urlrev = tagdetector2.newest_tag_revision() bricks@509: bricks@509: self.assertEquals(len(tags), 3) bricks@509: self.assertEquals(urlrev[0], "tag2") bricks@509: bricks@509: tagdetector3 = git.TagDetector(dirname, "another*", clonedir) bricks@509: tags = tagdetector3.list_tags() bricks@509: urlrev = tagdetector3.newest_tag_revision() bricks@509: bricks@509: self.assertEquals(len(tags), 1) bricks@509: self.assertEquals(urlrev[0], "anothertag")