Mercurial > treepkg
view test/test_git.py @ 538:6fb5e8b74414
contrib: Do a more conservative approach (full sorting) to figure out
the youngest debs. This _much_ slower but it works correctly.
TODO: make the heapq.nsmallest() work correct.
author | Sascha Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 10 Jan 2011 14:58:51 +0000 |
parents | c4288095887f |
children |
line wrap: on
line source
# Copyright (C) 2010 by Intevation GmbH # Authors: # Bjoern Ricks <bjoern.ricks@intevation.de> # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with the software for details. """Tests for the treepkg.git module""" import unittest import os import treepkg.run as run from treepkg.cmdexpand import cmdexpand from filesupport import FileTestMixin import treepkg.git as git class TestTagDetector(unittest.TestCase, FileTestMixin): def test_tag(self): dirname = self.create_test_specific_temp_dir() repodir = self.create_temp_dir("repo") clonedir = os.path.join(dirname, "clone") run.call(cmdexpand("git init -q"), cwd=repodir) file = open(os.path.join(repodir, "tmp"), "w") file.write("test") file.close() run.call(cmdexpand("git add tmp"), cwd=repodir) run.call(cmdexpand("git commit -m \"Add tmp file\""), cwd=repodir) run.call(cmdexpand("git tag tag1"), cwd=repodir) run.call(cmdexpand("git tag tag2"), cwd=repodir) run.call(cmdexpand("git tag anothertag"), cwd=repodir) tagdetector1 = git.TagDetector(repodir, "tag*", clonedir) tags = tagdetector1.list_tags() urlrev = tagdetector1.newest_tag_revision() self.assertEquals(len(tags), 2) self.assertEquals(urlrev[0], "tag2") tagdetector2 = git.TagDetector(dirname, "*tag*", clonedir) tags = tagdetector2.list_tags() urlrev = tagdetector2.newest_tag_revision() self.assertEquals(len(tags), 3) self.assertEquals(urlrev[0], "tag2") tagdetector3 = git.TagDetector(dirname, "another*", clonedir) tags = tagdetector3.list_tags() urlrev = tagdetector3.newest_tag_revision() self.assertEquals(len(tags), 1) self.assertEquals(urlrev[0], "anothertag")