changeset 495:ca95be9d033a

add tests for determine debian upstream version fix calling determine_upstream_version in determine_package_version update authors
author Bjoern Ricks <bricks@intevation.de>
date Thu, 14 Oct 2010 07:49:50 +0000
parents 31b64ebe4b42
children d85af9a6c93a
files test/test_packager.py test/test_util.py treepkg/packager.py treepkg/util.py
diffstat 4 files changed, 112 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/test/test_packager.py	Wed Oct 13 16:26:53 2010 +0000
+++ b/test/test_packager.py	Thu Oct 14 07:49:50 2010 +0000
@@ -1,6 +1,7 @@
-# Copyright (C) 2007, 2008, 2009 by Intevation GmbH
+# Copyright (C) 2007-2010 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh@intevation.de>
+# 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.
@@ -371,6 +372,104 @@
         format = srcpkg.get_debian_source_format(pkgbasedir)
         self.assertEqual("1.0", format)
 
+class TestDetermineUpstreamVersion(unittest.TestCase, FileTestMixin):
+
+    def test_debian_upstream_version(self):
+        trackdir = self.create_files("track",
+                                     [("debian",
+                                       [("changelog", """\
+testpkg (1.0.1~-1abc.173) unstable; urgency=low
+
+  * Initial version
+
+ -- TreePKG <treepkg@example.com>  Thu,  8 Mar 2007 18:34:39 +0100
+"""
+                                     )]),
+                                     ("pkg",
+                                       [("704195-0",
+                                         [("status",
+                                            ("TreePackagerStatus 0.0\n"
+                                            "status: binary_package_created\n"
+                                            "start: 2007-09-10 17:16:48\n"
+                                            "stop: 2007-09-11 00:07:36\n")),
+                                          ("src", []),
+                                          ("binary", [])
+                                         ]
+                                        )]
+                                      )]
+                                   )
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
+        revpkg = RevisionPackager(track, 704195, 0)
+        srcpkg = SourcePackager(revpkg)
+
+        pkgbasedir = trackdir
+        version = srcpkg.determine_upstream_version()
+        self.assertEqual("1.0.1~", version)
+
+    def test_debian_native_upstream_version(self):
+        trackdir = self.create_files("track",
+                                     [("debian",
+                                       [("changelog", """\
+testpkg (1.0.1) unstable; urgency=low
+
+  * Initial version
+
+ -- TreePKG <treepkg@example.com>  Thu,  8 Mar 2007 18:34:39 +0100
+"""
+                                     )]),
+                                     ("pkg",
+                                       [("704195-0",
+                                         [("status",
+                                            ("TreePackagerStatus 0.0\n"
+                                            "status: binary_package_created\n"
+                                            "start: 2007-09-10 17:16:48\n"
+                                            "stop: 2007-09-11 00:07:36\n")),
+                                          ("src", []),
+                                          ("binary", [])
+                                         ]
+                                        )]
+                                      )]
+                                   )
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
+        revpkg = RevisionPackager(track, 704195, 0)
+        srcpkg = SourcePackager(revpkg)
+
+        pkgbasedir = trackdir
+        version = srcpkg.determine_upstream_version()
+        self.assertEqual("1.0.1", version)
+
+    def test_debian_epoch_upstream_version(self):
+        trackdir = self.create_files("track",
+                                     [("debian",
+                                       [("changelog", """\
+testpkg (4:1.0.1-1abc3) unstable; urgency=low
+
+  * Initial version
+
+ -- TreePKG <treepkg@example.com>  Thu,  8 Mar 2007 18:34:39 +0100
+"""
+                                     )]),
+                                     ("pkg",
+                                       [("704195-0",
+                                         [("status",
+                                            ("TreePackagerStatus 0.0\n"
+                                            "status: binary_package_created\n"
+                                            "start: 2007-09-10 17:16:48\n"
+                                            "stop: 2007-09-11 00:07:36\n")),
+                                          ("src", []),
+                                          ("binary", [])
+                                         ]
+                                        )]
+                                      )]
+                                   )
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
+        revpkg = RevisionPackager(track, 704195, 0)
+        srcpkg = SourcePackager(revpkg)
+
+        pkgbasedir = trackdir
+        version = srcpkg.determine_upstream_version()
+        self.assertEqual("1.0.1", version)
+
 class TestRevisionPackager(unittest.TestCase, FileTestMixin):
 
     def test_list_source_files(self):
--- a/test/test_util.py	Wed Oct 13 16:26:53 2010 +0000
+++ b/test/test_util.py	Thu Oct 14 07:49:50 2010 +0000
@@ -1,6 +1,7 @@
 # Copyright (C) 2007, 2008 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh@intevation.de>
+# 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.
--- a/treepkg/packager.py	Wed Oct 13 16:26:53 2010 +0000
+++ b/treepkg/packager.py	Thu Oct 14 07:49:50 2010 +0000
@@ -1,6 +1,8 @@
-# Copyright (C) 2007, 2008, 2009 by Intevation GmbH
+# Copyright (C) 2007-2010 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh@intevation.de>
+# Bjoern Ricks    <bjoern.ricks@intevation.de>
+# Andre Heinecke  <andre.heinecke@intevation.de>
 #
 # This program is free software under the GPL (>=v2)
 # Read the file COPYING coming with the software for details.
@@ -50,11 +52,14 @@
     def __init__(self, parent):
         self.parent = parent
 
-    def determine_upstream_version(self, directory)
+    def determine_upstream_version(self, directory=None):
         """
             Tries to parse the upstream version from a source directory
             and returns it as a string.
         """
+
+        if not directory:
+            directory = self.track.checkout_dir
         # TODO: it should be possible to select which files should be searched
         # for upstream_version
 
@@ -104,7 +109,7 @@
         rules_revision = self.parent.rules_revision
         pkg_revision = self.parent.pkg_revision
         pkg_date = time.strftime("%Y%m%d", time.localtime())
-        upstream_version = determine_upstream_version(directory)
+        upstream_version = self.determine_upstream_version(directory)
         version_dict = locals().copy()
         if type(additionals).__name__=='dict':
             version_dict.update(additionals)
--- a/treepkg/util.py	Wed Oct 13 16:26:53 2010 +0000
+++ b/treepkg/util.py	Thu Oct 14 07:49:50 2010 +0000
@@ -1,6 +1,8 @@
-# Copyright (C) 2007, 2008 by Intevation GmbH
+# Copyright (C) 2007, 2008, 2010 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh@intevation.de>
+# Bjoern Ricks    <bjoern.ricks@intevation.de>
+# Andre Heinecke  <andre.heinecke@intevation.de>
 #
 # This program is free software under the GPL (>=v2)
 # Read the file COPYING coming with the software for details.
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)