comparison test/test_packager.py @ 185:e1c7cd896310

Rework test/filesupport.py so that test cases always use their own temporary directory. Before, the test cases had to ensure this themselves. Adapt the test cases.
author Bernhard Herzog <bh@intevation.de>
date Thu, 26 Jun 2008 16:23:26 +0000
parents 5155b4f9443d
children e83db4482aab
comparison
equal deleted inserted replaced
184:83c77307ffb1 185:e1c7cd896310
99 """), 99 """),
100 ("rules", "binary: echo binary")])] 100 ("rules", "binary: echo binary")])]
101 101
102 102
103 def setUp(self): 103 def setUp(self):
104 self.svndir = self.create_temp_dir(self.id() + "-svn") 104 self.svndir = self.create_temp_dir("svn")
105 self.svnworkdir = self.create_temp_dir(self.id() + "-svnwork") 105 self.svnworkdir = self.create_temp_dir("svnwork")
106 self.trackdir = self.create_temp_dir(self.id() + "-track") 106 self.trackdir = self.create_files("track", self.debian_files)
107 self.create_files(self.trackdir, self.debian_files)
108 self.svn_url = create_svn_repository(self.svndir) + "/trunk" 107 self.svn_url = create_svn_repository(self.svndir) + "/trunk"
109 subversion.checkout(self.svn_url, self.svnworkdir) 108 subversion.checkout(self.svn_url, self.svnworkdir)
110 for message, files in self.revisions: 109 for message, files in self.revisions:
111 add_svn_files(self.svnworkdir, files, message) 110 add_svn_files(self.svnworkdir, files, message)
112 111
198 197
199 198
200 class TestPackageGroupStop(unittest.TestCase, FileTestMixin): 199 class TestPackageGroupStop(unittest.TestCase, FileTestMixin):
201 200
202 def setUp(self): 201 def setUp(self):
203 self.trackdir = self.create_temp_dir(self.id() + "-track") 202 self.trackdir = self.create_temp_dir("track")
204 self.instructions_file = os.path.join(self.trackdir, "instructions") 203 self.instructions_file = os.path.join(self.trackdir, "instructions")
205 204
206 def group(self, do_package=True, do_stop=True): 205 def group(self, do_package=True, do_stop=True):
207 return PackagerGroup([StoppingTrack(do_package, do_stop, 206 return PackagerGroup([StoppingTrack(do_package, do_stop,
208 self.instructions_file, 207 self.instructions_file,
244 self.failUnless(group.check_package_tracks()) 243 self.failUnless(group.check_package_tracks())
245 244
246 245
247 class TestPackageTrack(unittest.TestCase, FileTestMixin): 246 class TestPackageTrack(unittest.TestCase, FileTestMixin):
248 247
249 def setUp(self): 248 # def setUp(self):
250 self.trackdir = self.create_temp_dir(self.id() + "-track") 249 # self.trackdir = self.create_temp_dir("track")
251 250
252 def test_get_revision_numbers(self): 251 def test_get_revision_numbers(self):
253 # Note: The revisions in the pkg dir are not ordered so that we 252 # Note: The revisions in the pkg dir are not ordered so that we
254 # can check whether get_revision_numbers returns a sorted list 253 # can check whether get_revision_numbers returns a sorted list
255 # of revisions 254 # of revisions
256 self.create_files(self.trackdir, 255 trackdir = self.create_files("track",
257 [("pkg", 256 [("pkg",
258 [("704195-1", 257 [("704195-1",
259 [("status", ""), 258 [("status", ""),
260 ("src", []), 259 ("src", []),
261 ("binary", [])]), 260 ("binary", [])]),
262 ("702432-1", 261 ("702432-1",
263 [("status", ""), 262 [("status", ""),
264 ("src", []), 263 ("src", []),
265 ("binary", [])])])]) 264 ("binary", [])])])])
266 track = PackageTrack("testtrack", self.trackdir, "", "", "", "", "") 265 track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
267 self.assertEquals(track.get_revision_numbers(), [702432, 704195]) 266 self.assertEquals(track.get_revision_numbers(), [702432, 704195])
268 267
269 def test_last_packaged_revision_with_no_revisions(self): 268 def test_last_packaged_revision_with_no_revisions(self):
270 self.create_files(self.trackdir, [("pkg", [])]) 269 trackdir = self.create_files("track", [("pkg", [])])
271 track = PackageTrack("testtrack", self.trackdir, "", "", "", "", "") 270 track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
272 self.assertEquals(track.last_packaged_revision(), -1) 271 self.assertEquals(track.last_packaged_revision(), -1)
273 272
274 def test_last_packaged_revision_several_revisions(self): 273 def test_last_packaged_revision_several_revisions(self):
275 self.create_files(self.trackdir, 274 trackdir = self.create_files("track",
276 [("pkg", 275 [("pkg",
277 [("704195-1", 276 [("704195-1",
278 [("status", ""), 277 [("status", ""),
279 ("src", []), 278 ("src", []),
280 ("binary", [])]), 279 ("binary", [])]),
281 ("702432-1", 280 ("702432-1",
282 [("status", ""), 281 [("status", ""),
283 ("src", []), 282 ("src", []),
284 ("binary", [])])])]) 283 ("binary", [])])])])
285 track = PackageTrack("testtrack", self.trackdir, "", "", "", "", "") 284 track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
286 self.assertEquals(track.last_packaged_revision(), 704195) 285 self.assertEquals(track.last_packaged_revision(), 704195)
287 286
288 287
289 class TestRevisionPackager(unittest.TestCase, FileTestMixin): 288 class TestRevisionPackager(unittest.TestCase, FileTestMixin):
290 289
291 def setUp(self): 290 # def setUp(self):
292 self.trackdir = self.create_temp_dir(self.id() + "-track") 291 # self.trackdir = self.create_temp_dir("track")
293 292
294 def test_list_source_files(self): 293 def test_list_source_files(self):
295 # Note: The revisions in the pkg dir are not ordered so that we 294 # Note: The revisions in the pkg dir are not ordered so that we
296 # can check whether get_revision_numbers returns a sorted list 295 # can check whether get_revision_numbers returns a sorted list
297 # of revisions 296 # of revisions
298 self.create_files(self.trackdir, 297 trackdir = self.create_files("track",
299 [("pkg", 298 [("pkg",
300 [("704195-1", 299 [("704195-1",
301 [("status", 300 [("status",
302 ("TreePackagerStatus 0.0\n" 301 ("TreePackagerStatus 0.0\n"
303 "status: binary_package_created\n" 302 "status: binary_package_created\n"
304 "start: 2007-09-10 17:16:48\n" 303 "start: 2007-09-10 17:16:48\n"
305 "stop: 2007-09-11 00:07:36\n")), 304 "stop: 2007-09-11 00:07:36\n")),
306 ("src", [("test_1.0.orig.tar.gz", ""), 305 ("src", [("test_1.0.orig.tar.gz", ""),
307 ("test_1.0-1.diff.gz", ""), 306 ("test_1.0-1.diff.gz", ""),
308 ("test_1.0-1.dsc", "")]), 307 ("test_1.0-1.dsc", "")]),
309 ("binary", [])]), 308 ("binary", [])]),
310 ("702432-1", 309 ("702432-1",
311 [("status", ""), 310 [("status", ""),
312 ("src", []), 311 ("src", []),
313 ("binary", [])])])]) 312 ("binary", [])])])])
314 track = PackageTrack("testtrack", self.trackdir, "", "", "", "", "") 313 track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
315 revpkg = RevisionPackager(track, 704195) 314 revpkg = RevisionPackager(track, 704195)
316 srcdir = os.path.join(self.trackdir, "pkg", "704195-1", "src") 315 srcdir = os.path.join(trackdir, "pkg", "704195-1", "src")
317 self.assertEquals(revpkg.list_source_files(), 316 self.assertEquals(revpkg.list_source_files(),
318 [os.path.join(srcdir, filename) 317 [os.path.join(srcdir, filename)
319 for filename in ["test_1.0-1.diff.gz", 318 for filename in ["test_1.0-1.diff.gz",
320 "test_1.0-1.dsc", 319 "test_1.0-1.dsc",
321 "test_1.0.orig.tar.gz"]]) 320 "test_1.0.orig.tar.gz"]])
322 321
323 def test_list_binary_files(self): 322 def test_list_binary_files(self):
324 # Note: The revisions in the pkg dir are not ordered so that we 323 # Note: The revisions in the pkg dir are not ordered so that we
325 # can check whether get_revision_numbers returns a sorted list 324 # can check whether get_revision_numbers returns a sorted list
326 # of revisions 325 # of revisions
327 self.create_files(self.trackdir, 326 trackdir = self.create_files("track",
328 [("pkg", 327 [("pkg",
329 [("704195-1", 328 [("704195-1",
330 [("status", 329 [("status",
331 ("TreePackagerStatus 0.0\n" 330 ("TreePackagerStatus 0.0\n"
332 "status: binary_package_created\n" 331 "status: binary_package_created\n"
333 "start: 2007-09-10 17:16:48\n" 332 "start: 2007-09-10 17:16:48\n"
334 "stop: 2007-09-11 00:07:36\n")), 333 "stop: 2007-09-11 00:07:36\n")),
335 ("src", []), 334 ("src", []),
336 ("binary", [("test_1.0-1_i386.deb", ""), 335 ("binary",
337 ("test_1.0-1_i386.changes", "")])]), 336 [("test_1.0-1_i386.deb", ""),
338 ("702432-1", 337 ("test_1.0-1_i386.changes", "")])]),
339 [("status", ""), 338 ("702432-1",
340 ("src", []), 339 [("status", ""),
341 ("binary", [])])])]) 340 ("src", []),
342 track = PackageTrack("testtrack", self.trackdir, "", "", "", "", "") 341 ("binary", [])])])])
342 track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
343 revpkg = RevisionPackager(track, 704195) 343 revpkg = RevisionPackager(track, 704195)
344 bindir = os.path.join(self.trackdir, "pkg", "704195-1", "binary") 344 bindir = os.path.join(trackdir, "pkg", "704195-1", "binary")
345 self.assertEquals(revpkg.list_binary_files(), 345 self.assertEquals(revpkg.list_binary_files(),
346 [os.path.join(bindir, filename) 346 [os.path.join(bindir, filename)
347 for filename in ["test_1.0-1_i386.changes", 347 for filename in ["test_1.0-1_i386.changes",
348 "test_1.0-1_i386.deb"]]) 348 "test_1.0-1_i386.deb"]])
349 349
366 ("revonly.py", "\n".join(["class RevisionPackager:", 366 ("revonly.py", "\n".join(["class RevisionPackager:",
367 " pass", 367 " pass",
368 ""]))])] 368 ""]))])]
369 369
370 def setUp(self): 370 def setUp(self):
371 self.directory = self.create_temp_dir(self.id()) 371 self.directory = self.create_files("a_module", self.files)
372 self.create_files(self.directory, self.files)
373 self.old_path = sys.path 372 self.old_path = sys.path
374 sys.path = [self.directory] + sys.path 373 sys.path = [self.directory] + sys.path
375 374
376 def tearDown(self): 375 def tearDown(self):
377 sys.path = self.old_path 376 sys.path = self.old_path
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)