changeset 95:8f1c72135ea6

Make PackagerTest more flexible to make it easier to add tests
author Bernhard Herzog <bh@intevation.de>
date Mon, 26 Nov 2007 14:28:47 +0000
parents 0c13a84a67dd
children efbd66b13f51
files test/test_packager.py
diffstat 1 files changed, 23 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/test/test_packager.py	Mon Nov 26 14:15:52 2007 +0000
+++ b/test/test_packager.py	Mon Nov 26 14:28:47 2007 +0000
@@ -105,15 +105,8 @@
         self.create_files(self.trackdir, self.debian_files)
         self.svn_url = create_svn_repository(self.svndir) + "/trunk"
         subversion.checkout(self.svn_url, self.svnworkdir)
-        add_svn_files(self.svnworkdir, self.revisions[0],
-                      "Initial version")
-
-
-class TestPackager(PackagerTest):
-
-    revisions = [
-        [("README", "and miles to go before I sleep")],
-        ]
+        for message, files in self.revisions:
+            add_svn_files(self.svnworkdir, files, message)
 
     def runtest(self, debrevision, **extra_track_args):
         rootcmd = os.path.join(os.path.dirname(__file__), os.pardir, "test",
@@ -127,15 +120,30 @@
         group = PackagerGroup([track], 1)
         group.check_package_tracks()
 
+        # determine version that has been packaged.  This assumes that
+        # check_package_tracks will leave the checkout in the revision
+        # that was actually packaged.
+        version = subversion.last_changed_revision(self.svn_url)
+
         # Now check the source and binary package files
-        pkgdir = os.path.join(self.trackdir, "pkg", "2-1")
+        pkgdir = os.path.join(self.trackdir, "pkg", "%d-1" % version)
         self.assertEquals(sorted(os.listdir(os.path.join(pkgdir, "src"))),
-                          ["testpkg_2-%s.diff.gz" % debrevision,
-                           "testpkg_2-%s.dsc" % debrevision,
-                           "testpkg_2.orig.tar.gz"])
+                          [name % locals() for name in
+                           ["testpkg_%(version)d-%(debrevision)s.diff.gz",
+                            "testpkg_%(version)d-%(debrevision)s.dsc",
+                            "testpkg_%(version)d.orig.tar.gz"]])
         self.assertEquals(sorted(os.listdir(os.path.join(pkgdir, "binary"))),
-                          ["testpkg_2-%s_all.deb" % debrevision,
-                           "testpkg_2-%s_i386.changes" % debrevision])
+                          [name % locals() for name in
+                           ["testpkg_%(version)d-%(debrevision)s_all.deb",
+                           "testpkg_%(version)d-%(debrevision)s_i386.changes"]])
+
+
+class TestPackager(PackagerTest):
+
+    revisions = [
+        ("Initial Revision",
+         [("README", "and miles to go before I sleep")]),
+        ]
 
     def test_default_debrevision_prefix(self):
         self.runtest("treepkg1")
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)