bh@282: # Copyright (C) 2008, 2009 by Intevation GmbH
bh@282: # Authors:
bh@282: # Bernhard Herzog <bh@intevation.de>
bh@282: #
bh@282: # This program is free software under the GPL (>=v2)
bh@282: # Read the file COPYING coming with the software for details.
bh@282: 
bh@282: """Tests for the treepkg.subversion module"""
bh@282: 
bh@282: 
bh@282: import unittest
bh@282: 
bh@282: from treepkg.subversion import extract_tag_revisions
bh@282: 
bh@282: 
bh@282: class TestTagDetector(unittest.TestCase):
bh@282: 
bh@282:     def test_tag_changes_count_one_copy_command(self):
bh@282:         xml = """\
bh@282: <?xml version="1.0"?>
bh@282: <log>
bh@282: <logentry
bh@282:    revision="1001832">
bh@282: <author>tmcguire</author>
bh@282: <date>2009-07-24T11:01:19.722901Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    action="M">/branches/kdepim/enterprise/kdepim/kontact/src/main.cpp</path>
bh@282: <path
bh@282:    action="M">/branches/kdepim/enterprise/kdepim/kmail/kmversion.h</path>
bh@282: <path
bh@282:    action="M">/branches/kdepim/enterprise/kdepim/korganizer/version.h</path>
bh@282: </paths>
bh@282: <msg>SVN_SILENT Update version numbers for today's release.</msg>
bh@282: </logentry>
bh@282: <logentry
bh@282:    revision="1001837">
bh@282: <author>tmcguire</author>
bh@282: <date>2009-07-24T11:02:47.403605Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    copyfrom-path="/branches/kdepim/enterprise/kdepim"
bh@282:    copyfrom-rev="1001836"
bh@282:    action="A">/tags/kdepim/enterprise35.0.20090724.1001831/kdepim</path>
bh@282: </paths>
bh@282: <msg>SVN_SILENT Tag kdepim.</msg>
bh@282: </logentry>
bh@282: <logentry
bh@282:    revision="1004164">
bh@282: <author>winterz</author>
bh@282: <date>2009-07-29T13:23:42.262028Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    action="M">/tags/kdepim/enterprise35.0.20090724.1001831/kdepim/libkcal/scheduler.cpp</path>
bh@282: </paths>
bh@282: <msg>merge SVN commit 1004159 by winterz:
bh@282: 
bh@282: Allow an attendee to decline an new invitation without getting the error
bh@282: message that the event couldn't be found in their calendar.
bh@282: kolab/issue3780
bh@282: 
bh@282: </msg>
bh@282: </logentry>
bh@282: <logentry
bh@282:    revision="1004558">
bh@282: <author>winterz</author>
bh@282: <date>2009-07-30T13:34:18.385413Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    action="M">/tags/kdepim/enterprise35.0.20090724.1001831/kdepim/kmail/newfolderdialog.cpp</path>
bh@282: </paths>
bh@282: <msg>merge SVN commit 1004535 by tmcguire:
bh@282: 
bh@282: Fix silly crash when creating a folder.
bh@282: 
bh@282: kolab/issue3777
bh@282: </msg>
bh@282: </logentry>
bh@282: <logentry
bh@282:    revision="1004604">
bh@282: <author>winterz</author>
bh@282: <date>2009-07-30T15:25:19.331744Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    action="M">/tags/kdepim/enterprise35.0.20090724.1001831/kdepim/libkcal/incidenceformatter.cpp</path>
bh@282: </paths>
bh@282: <msg>merge SVN commit 1004601 by winterz:
bh@282: 
bh@282: possible fix for kolab/issue3724 and kolab/issue3780, whereby multiple
bh@282: persons having write access to a folder can confuse things for other
bh@282: users accessing that folder.
bh@282: 
bh@282: </msg>
bh@282: </logentry>
bh@282: </log>
bh@282: """
bh@282:         #
bh@282: 
bh@282:         self.assertEquals(extract_tag_revisions(xml),
bh@282:                           ["1001837", "1004164", "1004558", "1004604"])
bh@282: 
bh@282: 
bh@282:     def test_tag_changes_count_two_copy_commands(self):
bh@282:         xml = """\
bh@282: <?xml version="1.0"?>
bh@282: <log>
bh@282: <logentry
bh@282:    revision="901832">
bh@282: <author>tmcguire</author>
bh@282: <date>2009-07-24T11:01:19.722901Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    action="M">/branches/kdepim/enterprise/kdepim/kontact/src/main.cpp</path>
bh@282: <path
bh@282:    action="M">/branches/kdepim/enterprise/kdepim/kmail/kmversion.h</path>
bh@282: <path
bh@282:    action="M">/branches/kdepim/enterprise/kdepim/korganizer/version.h</path>
bh@282: </paths>
bh@282: <msg>SVN_SILENT Update version numbers for today's release.</msg>
bh@282: </logentry>
bh@282: <logentry
bh@282:    revision="901837">
bh@282: <author>tmcguire</author>
bh@282: <date>2009-07-24T11:02:47.403605Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    copyfrom-path="/branches/kdepim/enterprise/kdepim"
bh@282:    copyfrom-rev="1001836"
bh@282:    action="A">/tags/kdepim/enterprise35.0.20090724.1001831/kdepim</path>
bh@282: </paths>
bh@282: <msg>SVN_SILENT Tag kdepim.</msg>
bh@282: </logentry>
bh@282: <logentry
bh@282:    revision="1004164">
bh@282: <author>winterz</author>
bh@282: <date>2009-07-29T13:23:42.262028Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    action="M">/tags/kdepim/enterprise35.0.20090724.1001831/kdepim/libkcal/scheduler.cpp</path>
bh@282: </paths>
bh@282: <msg>merge SVN commit 1004159 by winterz:
bh@282: 
bh@282: Allow an attendee to decline an new invitation without getting the error
bh@282: message that the event couldn't be found in their calendar.
bh@282: kolab/issue3780
bh@282: 
bh@282: </msg>
bh@282: </logentry>
bh@282: <logentry
bh@282:    revision="1004558">
bh@282: <author>winterz</author>
bh@282: <date>2009-07-30T13:34:18.385413Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    action="M">/tags/kdepim/enterprise35.0.20090724.1001831/kdepim/kmail/newfolderdialog.cpp</path>
bh@282: </paths>
bh@282: <msg>merge SVN commit 1004535 by tmcguire:
bh@282: 
bh@282: Fix silly crash when creating a folder.
bh@282: 
bh@282: kolab/issue3777
bh@282: </msg>
bh@282: </logentry>
bh@282: <logentry
bh@282:    revision="1004604">
bh@282: <author>winterz</author>
bh@282: <date>2009-07-30T15:25:19.331744Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    action="M">/tags/kdepim/enterprise35.0.20090724.1001831/kdepim/libkcal/incidenceformatter.cpp</path>
bh@282: </paths>
bh@282: <msg>merge SVN commit 1004601 by winterz:
bh@282: 
bh@282: possible fix for kolab/issue3724 and kolab/issue3780, whereby multiple
bh@282: persons having write access to a folder can confuse things for other
bh@282: users accessing that folder.
bh@282: 
bh@282: </msg>
bh@282: </logentry>
bh@282: <logentry
bh@282:    revision="1005000">
bh@282: <author>somebody</author>
bh@282: <date>2009-07-24T12:02:47.403605Z</date>
bh@282: <paths>
bh@282: <path
bh@282:    copyfrom-path="/branches/kdepim/enterprise/kdepim"
bh@282:    copyfrom-rev="1001836"
bh@282:    action="A">/tags/kdepim/enterprise35.0.20090724.1001831/kdepim</path>
bh@282: </paths>
bh@282: <msg>ficticious commit that looks like the earlier copy that created the tag.
bh@282: </msg>
bh@282: </logentry>
bh@282: </log>
bh@282: """
bh@282:         #
bh@282: 
bh@282:         self.assertEquals(extract_tag_revisions(xml),
bh@282:                           ["901837", "1004164", "1004558", "1004604",
bh@282:                            "1005000"])