view test/test_git.py @ 518:452c5670ec6b

fix git tag detector usage in enterprise packager working copy paths were missing
author Bjoern Ricks <bricks@intevation.de>
date Wed, 10 Nov 2010 13:32:37 +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")
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)