comparison 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
comparison
equal deleted inserted replaced
250:b3f9cc956acc 251:243f206574cb
8 8
9 import sys 9 import sys
10 import os 10 import os
11 import difflib 11 import difflib
12 import unittest 12 import unittest
13 from datetime import datetime, timedelta
13 14
14 from filesupport import FileTestMixin 15 from filesupport import FileTestMixin
15 16
16 from treepkg.run import call, capture_output, SubprocessError 17 from treepkg.run import call, capture_output, SubprocessError
18 from treepkg.status import RevisionStatus
17 19
18 20
19 def package_track_files(track, version, binaries, revisions): 21 def package_track_files(track, version, binaries, revisions):
20 src_templates = ["%s_%s.%%s%s" % (track, version, suffix) 22 src_templates = ["%s_%s.%%s%s" % (track, version, suffix)
21 for suffix in [".orig.tar.gz", "-1.diff.gz", "-1.dsc"]] 23 for suffix in [".orig.tar.gz", "-1.diff.gz", "-1.dsc"]]
22 bin_templates = ["%s_%s.%%s-1_i386.deb" % (basename, version) 24 bin_templates = ["%s_%s.%%s-1_i386.deb" % (basename, version)
23 for basename in binaries] 25 for basename in binaries]
26
27 start_time = datetime.now()
28 build_duration = timedelta(minutes=30)
29 check_interval = timedelta(minutes=60)
30
31 package_dirs = []
32 for revision in revisions:
33 rev, rules_rev = revision
34 status = RevisionStatus(None)
35 status.binary_package_created()
36 status.start = start_time
37 status.stop = start_time + build_duration
38 start_time += check_interval
39
40 package_dirs.append(("%s-%s" % (rev, rules_rev),
41 [("status", "".join(status.serialize())),
42 ("src", [(template % (rev,), "")
43 for template in src_templates]),
44 ("binary", [(template % (rev,), "")
45 for template in bin_templates])]))
24 return (track, 46 return (track,
25 [("pkg", [("%s-%s" % (rev, rules_rev), 47 [("pkg",
26 [("status", "TreePackagerStatus 0.0\n"), 48 package_dirs)])
27 ("src", [(template % (rev,), "") 49
28 for template in src_templates]),
29 ("binary", [(template % (rev,), "")
30 for template in bin_templates])])
31 for rev, rules_rev in revisions])])
32 50
33 class ListPackagesTest(unittest.TestCase, FileTestMixin): 51 class ListPackagesTest(unittest.TestCase, FileTestMixin):
34 52
35 treepkg_cfg_template = """\ 53 treepkg_cfg_template = """\
36 [DEFAULT] 54 [DEFAULT]
129 [(704195, 31), (702432, 47)])] 147 [(704195, 31), (702432, 47)])]
130 148
131 def test_listpackages_source(self): 149 def test_listpackages_source(self):
132 self.check_cmd(["--track=kdepim", "--source"], 150 self.check_cmd(["--track=kdepim", "--source"],
133 """\ 151 """\
134 kdepim/pkg/704195-31/src/kdepim_1.0.1.704195-1.diff.gz 152 kdepim/pkg/702432-47/src/kdepim_1.0.1.702432-1.diff.gz
135 kdepim/pkg/704195-31/src/kdepim_1.0.1.704195-1.dsc 153 kdepim/pkg/702432-47/src/kdepim_1.0.1.702432-1.dsc
136 kdepim/pkg/704195-31/src/kdepim_1.0.1.704195.orig.tar.gz 154 kdepim/pkg/702432-47/src/kdepim_1.0.1.702432.orig.tar.gz
137 """) 155 """)
138 156
139 def test_listpackages_binary(self): 157 def test_listpackages_binary(self):
140 self.check_cmd(["--track=kdepim", "--binary"], 158 self.check_cmd(["--track=kdepim", "--binary"],
141 """\ 159 """\
142 kdepim/pkg/704195-31/binary/kdepim_1.0.1.704195-1_i386.deb 160 kdepim/pkg/702432-47/binary/kdepim_1.0.1.702432-1_i386.deb
143 kdepim/pkg/704195-31/binary/kleopatra_1.0.1.704195-1_i386.deb 161 kdepim/pkg/702432-47/binary/kleopatra_1.0.1.702432-1_i386.deb
144 """) 162 """)
145 163
146 164
147 class TestListPackagesNoTrackNoRevision(ListPackagesTest): 165 class TestListPackagesNoTrackNoRevision(ListPackagesTest):
148 166
149 track_files = [package_track_files("kdepim", "1.0.1", 167 track_files = [package_track_files("kdepim", "1.0.1",
150 ["kdepim", "kleopatra"], 168 ["kdepim", "kleopatra"],
151 [(704195, 31), (702432, 47)]), 169 [(702432, 47),
170 (704195, 31)]),
152 package_track_files("kdepimlibs", "1.0.1", 171 package_track_files("kdepimlibs", "1.0.1",
153 ["kdepimlibs"], 172 ["kdepimlibs"],
154 [(803691, 4321), (803692, 4322)]), 173 [(803691, 4321),
174 (803692, 4322)]),
155 ] 175 ]
156 176
157 def test_listpackages_source(self): 177 def test_listpackages_source(self):
158 self.check_cmd(["--source"], 178 self.check_cmd(["--source"],
159 """\ 179 """\
199 219
200 class TestListPackagesMultipleRulesRevisions(ListPackagesTest): 220 class TestListPackagesMultipleRulesRevisions(ListPackagesTest):
201 221
202 track_files = [package_track_files("kdepim", "1.0.1", 222 track_files = [package_track_files("kdepim", "1.0.1",
203 ["kdepim", "kleopatra"], 223 ["kdepim", "kleopatra"],
204 [(704195, 31), (704195, 33), 224 [(702432, 47),
205 (702432, 47)]), 225 (704195, 31),
226 (704195, 33)]),
206 package_track_files("kdepimlibs", "1.0.1", 227 package_track_files("kdepimlibs", "1.0.1",
207 ["kdepimlibs"], 228 ["kdepimlibs"],
208 [(803691, 4321), (803692, 4322)]), 229 [(803691, 4321),
230 (803692, 4322)]),
209 ] 231 ]
210 232
211 def test_listpackages_source_no_rev(self): 233 def test_listpackages_source_no_rev(self):
212 self.check_cmd(["--source", "--track=kdepim"], 234 self.check_cmd(["--source", "--track=kdepim"],
213 """\ 235 """\
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)