diff test/test_listpackages.py @ 251:243f206574cb

Make bin/listpackages.py prefer the newest packages by start-time, not revision number. Change test_listpackages.py so that it uses more realistic status files for the individual revisions and adapt the test cases to the new behavior.
author Bernhard Herzog <bh@intevation.de>
date Thu, 09 Apr 2009 18:59:44 +0000
parents 5dd710b167d2
children 2e0b373414b8
line wrap: on
line diff
--- a/test/test_listpackages.py	Thu Apr 09 18:20:04 2009 +0000
+++ b/test/test_listpackages.py	Thu Apr 09 18:59:44 2009 +0000
@@ -10,10 +10,12 @@
 import os
 import difflib
 import unittest
+from datetime import datetime, timedelta
 
 from filesupport import FileTestMixin
 
 from treepkg.run import call, capture_output, SubprocessError
+from treepkg.status import RevisionStatus
 
 
 def package_track_files(track, version, binaries, revisions):
@@ -21,14 +23,30 @@
                      for suffix in [".orig.tar.gz", "-1.diff.gz", "-1.dsc"]]
     bin_templates = ["%s_%s.%%s-1_i386.deb" % (basename, version)
                      for basename in binaries]
+
+    start_time = datetime.now()
+    build_duration = timedelta(minutes=30)
+    check_interval = timedelta(minutes=60)
+
+    package_dirs = []
+    for revision in revisions:
+        rev, rules_rev = revision
+        status = RevisionStatus(None)
+        status.binary_package_created()
+        status.start = start_time
+        status.stop = start_time + build_duration
+        start_time += check_interval
+
+        package_dirs.append(("%s-%s" % (rev, rules_rev),
+                             [("status", "".join(status.serialize())),
+                              ("src", [(template % (rev,), "")
+                                       for template in src_templates]),
+                              ("binary", [(template % (rev,), "")
+                                          for template in bin_templates])]))
     return (track,
-            [("pkg", [("%s-%s" % (rev, rules_rev),
-                       [("status", "TreePackagerStatus 0.0\n"),
-                        ("src", [(template % (rev,), "")
-                                 for template in src_templates]),
-                        ("binary", [(template % (rev,), "")
-                                    for template in bin_templates])])
-                      for rev, rules_rev in revisions])])
+            [("pkg",
+              package_dirs)])
+
 
 class ListPackagesTest(unittest.TestCase, FileTestMixin):
 
@@ -131,16 +149,16 @@
     def test_listpackages_source(self):
         self.check_cmd(["--track=kdepim", "--source"],
                        """\
-kdepim/pkg/704195-31/src/kdepim_1.0.1.704195-1.diff.gz
-kdepim/pkg/704195-31/src/kdepim_1.0.1.704195-1.dsc
-kdepim/pkg/704195-31/src/kdepim_1.0.1.704195.orig.tar.gz
+kdepim/pkg/702432-47/src/kdepim_1.0.1.702432-1.diff.gz
+kdepim/pkg/702432-47/src/kdepim_1.0.1.702432-1.dsc
+kdepim/pkg/702432-47/src/kdepim_1.0.1.702432.orig.tar.gz
 """)
 
     def test_listpackages_binary(self):
         self.check_cmd(["--track=kdepim", "--binary"],
                        """\
-kdepim/pkg/704195-31/binary/kdepim_1.0.1.704195-1_i386.deb
-kdepim/pkg/704195-31/binary/kleopatra_1.0.1.704195-1_i386.deb
+kdepim/pkg/702432-47/binary/kdepim_1.0.1.702432-1_i386.deb
+kdepim/pkg/702432-47/binary/kleopatra_1.0.1.702432-1_i386.deb
 """)
 
 
@@ -148,10 +166,12 @@
 
     track_files = [package_track_files("kdepim", "1.0.1",
                                        ["kdepim", "kleopatra"],
-                                       [(704195, 31), (702432, 47)]),
+                                       [(702432, 47),
+                                        (704195, 31)]),
                    package_track_files("kdepimlibs", "1.0.1",
                                        ["kdepimlibs"],
-                                       [(803691, 4321), (803692, 4322)]),
+                                       [(803691, 4321),
+                                        (803692, 4322)]),
                    ]
 
     def test_listpackages_source(self):
@@ -201,11 +221,13 @@
 
     track_files = [package_track_files("kdepim", "1.0.1",
                                        ["kdepim", "kleopatra"],
-                                       [(704195, 31), (704195, 33),
-                                        (702432, 47)]),
+                                       [(702432, 47),
+                                        (704195, 31),
+                                        (704195, 33)]),
                    package_track_files("kdepimlibs", "1.0.1",
                                        ["kdepimlibs"],
-                                       [(803691, 4321), (803692, 4322)]),
+                                       [(803691, 4321),
+                                        (803692, 4322)]),
                    ]
 
     def test_listpackages_source_no_rev(self):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)