| 1 |
# vim: set ft=python ts=4 sw=4 expandtab: |
| 2 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
| 3 |
# |
| 4 |
# C E D A R |
| 5 |
# S O L U T I O N S "Software done right." |
| 6 |
# S O F T W A R E |
| 7 |
# |
| 8 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
| 9 |
# |
| 10 |
# Copyright (c) 2007,2010,2015 Kenneth J. Pronovici. |
| 11 |
# All rights reserved. |
| 12 |
# |
| 13 |
# This program is free software; you can redistribute it and/or |
| 14 |
# modify it under the terms of the GNU General Public License, |
| 15 |
# Version 2, as published by the Free Software Foundation. |
| 16 |
# |
| 17 |
# This program is distributed in the hope that it will be useful, |
| 18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 20 |
# |
| 21 |
# Copies of the GNU General Public License are available from |
| 22 |
# the Free Software Foundation website, http://www.gnu.org/. |
| 23 |
# |
| 24 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
| 25 |
# |
| 26 |
# Author : Kenneth J. Pronovici <[email protected]> |
| 27 |
# Language : Python 3 |
| 28 |
# Project : Cedar Backup, release 3 |
| 29 |
# Purpose : Tests DVD writer functionality. |
| 30 |
# |
| 31 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
| 32 |
|
| 33 |
######################################################################## |
| 34 |
# Module documentation |
| 35 |
######################################################################## |
| 36 |
|
| 37 |
""" |
| 38 |
Unit tests for CedarBackup3/writers/dvdwriter.py. |
| 39 |
|
| 40 |
Code Coverage |
| 41 |
============= |
| 42 |
|
| 43 |
This module contains individual tests for the public classes implemented in |
| 44 |
dvdwriter.py. |
| 45 |
|
| 46 |
Unfortunately, it's rather difficult to test this code in an automated |
| 47 |
fashion, even if you have access to a physical DVD writer drive. It's even |
| 48 |
more difficult to test it if you are running on some build daemon (think of |
| 49 |
a Debian autobuilder) which can't be expected to have any hardware or any |
| 50 |
media that you could write to. Because of this, there aren't any tests |
| 51 |
below that actually cause DVD media to be written to. |
| 52 |
|
| 53 |
As a compromise, complicated parts of the implementation are in terms of |
| 54 |
private static methods with well-defined behaviors. Normally, I prefer to |
| 55 |
only test the public interface to class, but in this case, testing these few |
| 56 |
private methods will help give us some reasonable confidence in the code, |
| 57 |
even if we can't write a physical disc or can't run all of the tests. |
| 58 |
|
| 59 |
Naming Conventions |
| 60 |
================== |
| 61 |
|
| 62 |
I prefer to avoid large unit tests which validate more than one piece of |
| 63 |
functionality, and I prefer to avoid using overly descriptive (read: long) |
| 64 |
test names, as well. Instead, I use lots of very small tests that each |
| 65 |
validate one specific thing. These small tests are then named with an index |
| 66 |
number, yielding something like ``testAddDir_001`` or ``testValidate_010``. |
| 67 |
Each method has a docstring describing what it's supposed to accomplish. I |
| 68 |
feel that this makes it easier to judge how important a given failure is, |
| 69 |
and also makes it somewhat easier to diagnose and fix individual problems. |
| 70 |
|
| 71 |
Full vs. Reduced Tests |
| 72 |
====================== |
| 73 |
|
| 74 |
Some Cedar Backup regression tests require a specialized environment in |
| 75 |
order to run successfully. This environment won't necessarily be available |
| 76 |
on every build system out there (for instance, on a Debian autobuilder). |
| 77 |
Because of this, the default behavior is to run a "reduced feature set" test |
| 78 |
suite that has no surprising system, kernel or network requirements. There |
| 79 |
are no special dependencies for these tests. |
| 80 |
|
| 81 |
@author Kenneth J. Pronovici <[email protected]> |
| 82 |
""" |
| 83 |
|
| 84 |
|
| 85 |
######################################################################## |
| 86 |
# Import modules and do runtime validations |
| 87 |
######################################################################## |
| 88 |
|
| 89 |
import os |
| 90 |
import tempfile |
| 91 |
import unittest |
| 92 |
|
| 93 |
from CedarBackup3.testutil import buildPath, configureLogging, extractTar, findResources, removedir |
| 94 |
from CedarBackup3.writers.dvdwriter import MEDIA_DVDPLUSR, MEDIA_DVDPLUSRW, DvdWriter, MediaCapacity, MediaDefinition |
| 95 |
|
| 96 |
####################################################################### |
| 97 |
# Module-wide configuration and constants |
| 98 |
####################################################################### |
| 99 |
|
| 100 |
GB44 = 4.4 * 1024.0 * 1024.0 * 1024.0 # 4.4 GB |
| 101 |
GB44SECTORS = GB44 / 2048.0 # 4.4 GB in 2048-byte sectors |
| 102 |
|
| 103 |
DATA_DIRS = [ |
| 104 |
"./data", |
| 105 |
"./tests/data", |
| 106 |
] |
| 107 |
RESOURCES = [ |
| 108 |
"tree9.tar.gz", |
| 109 |
] |
| 110 |
|
| 111 |
|
| 112 |
####################################################################### |
| 113 |
# Test Case Classes |
| 114 |
####################################################################### |
| 115 |
|
| 116 |
############################ |
| 117 |
# TestMediaDefinition class |
| 118 |
############################ |
| 119 |
|
| 120 |
|
| 121 |
class TestMediaDefinition(unittest.TestCase): |
| 122 |
"""Tests for the MediaDefinition class.""" |
| 123 |
|
| 124 |
@classmethod |
| 125 |
def setUpClass(cls): |
| 126 |
configureLogging() |
| 127 |
|
| 128 |
def testConstructor_001(self): |
| 129 |
""" |
| 130 |
Test the constructor with an invalid media type. |
| 131 |
""" |
| 132 |
self.assertRaises(ValueError, MediaDefinition, 100) |
| 133 |
|
| 134 |
def testConstructor_002(self): |
| 135 |
""" |
| 136 |
Test the constructor with the ``MEDIA_DVDPLUSR`` media type. |
| 137 |
""" |
| 138 |
media = MediaDefinition(MEDIA_DVDPLUSR) |
| 139 |
self.assertEqual(MEDIA_DVDPLUSR, media.mediaType) |
| 140 |
self.assertEqual(False, media.rewritable) |
| 141 |
self.assertEqual(GB44SECTORS, media.capacity) |
| 142 |
|
| 143 |
def testConstructor_003(self): |
| 144 |
""" |
| 145 |
Test the constructor with the ``MEDIA_DVDPLUSRW`` media type. |
| 146 |
""" |
| 147 |
media = MediaDefinition(MEDIA_DVDPLUSRW) |
| 148 |
self.assertEqual(MEDIA_DVDPLUSRW, media.mediaType) |
| 149 |
self.assertEqual(True, media.rewritable) |
| 150 |
self.assertEqual(GB44SECTORS, media.capacity) |
| 151 |
|
| 152 |
|
| 153 |
########################## |
| 154 |
# TestMediaCapacity class |
| 155 |
########################## |
| 156 |
|
| 157 |
|
| 158 |
class TestMediaCapacity(unittest.TestCase): |
| 159 |
"""Tests for the MediaCapacity class.""" |
| 160 |
|
| 161 |
@classmethod |
| 162 |
def setUpClass(cls): |
| 163 |
configureLogging() |
| 164 |
|
| 165 |
def testConstructor_001(self): |
| 166 |
""" |
| 167 |
Test the constructor with valid, zero values |
| 168 |
""" |
| 169 |
capacity = MediaCapacity(0.0, 0.0) |
| 170 |
self.assertEqual(0.0, capacity.bytesUsed) |
| 171 |
self.assertEqual(0.0, capacity.bytesAvailable) |
| 172 |
|
| 173 |
def testConstructor_002(self): |
| 174 |
""" |
| 175 |
Test the constructor with valid, non-zero values. |
| 176 |
""" |
| 177 |
capacity = MediaCapacity(1.1, 2.2) |
| 178 |
self.assertEqual(1.1, capacity.bytesUsed) |
| 179 |
self.assertEqual(2.2, capacity.bytesAvailable) |
| 180 |
|
| 181 |
def testConstructor_003(self): |
| 182 |
""" |
| 183 |
Test the constructor with bytesUsed that is not a float. |
| 184 |
""" |
| 185 |
self.assertRaises(ValueError, MediaCapacity, 0.0, "ken") |
| 186 |
|
| 187 |
def testConstructor_004(self): |
| 188 |
""" |
| 189 |
Test the constructor with bytesAvailable that is not a float. |
| 190 |
""" |
| 191 |
self.assertRaises(ValueError, MediaCapacity, "a", 0.0) |
| 192 |
|
| 193 |
|
| 194 |
###################### |
| 195 |
# TestDvdWriter class |
| 196 |
###################### |
| 197 |
|
| 198 |
|
| 199 |
class TestDvdWriter(unittest.TestCase): |
| 200 |
"""Tests for the DvdWriter class.""" |
| 201 |
|
| 202 |
################ |
| 203 |
# Setup methods |
| 204 |
################ |
| 205 |
|
| 206 |
@classmethod |
| 207 |
def setUpClass(cls): |
| 208 |
configureLogging() |
| 209 |
|
| 210 |
def setUp(self): |
| 211 |
try: |
| 212 |
self.tmpdir = tempfile.mkdtemp() |
| 213 |
self.resources = findResources(RESOURCES, DATA_DIRS) |
| 214 |
except Exception as e: |
| 215 |
self.fail(e) |
| 216 |
|
| 217 |
def tearDown(self): |
| 218 |
removedir(self.tmpdir) |
| 219 |
|
| 220 |
################## |
| 221 |
# Utility methods |
| 222 |
################## |
| 223 |
|
| 224 |
def extractTar(self, tarname): |
| 225 |
"""Extracts a tarfile with a particular name.""" |
| 226 |
extractTar(self.tmpdir, self.resources["%s.tar.gz" % tarname]) |
| 227 |
|
| 228 |
def buildPath(self, components): |
| 229 |
"""Builds a complete search path from a list of components.""" |
| 230 |
components.insert(0, self.tmpdir) |
| 231 |
return buildPath(components) |
| 232 |
|
| 233 |
def getFileContents(self, resource): |
| 234 |
"""Gets contents of named resource as a list of strings.""" |
| 235 |
path = self.resources[resource] |
| 236 |
with open(path) as f: |
| 237 |
return f.readlines() |
| 238 |
|
| 239 |
################### |
| 240 |
# Test constructor |
| 241 |
################### |
| 242 |
|
| 243 |
def testConstructor_001(self): |
| 244 |
""" |
| 245 |
Test with an empty device. |
| 246 |
""" |
| 247 |
self.assertRaises(ValueError, DvdWriter, None) |
| 248 |
|
| 249 |
def testConstructor_002(self): |
| 250 |
""" |
| 251 |
Test with a device only. |
| 252 |
""" |
| 253 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 254 |
self.assertEqual("/dev/dvd", dvdwriter.device) |
| 255 |
self.assertEqual(None, dvdwriter.scsiId) |
| 256 |
self.assertEqual("/dev/dvd", dvdwriter.hardwareId) |
| 257 |
self.assertEqual(None, dvdwriter.driveSpeed) |
| 258 |
self.assertEqual(MEDIA_DVDPLUSRW, dvdwriter.media.mediaType) |
| 259 |
self.assertEqual(True, dvdwriter.deviceHasTray) |
| 260 |
self.assertEqual(True, dvdwriter.deviceCanEject) |
| 261 |
|
| 262 |
def testConstructor_003(self): |
| 263 |
""" |
| 264 |
Test with a device and valid SCSI id. |
| 265 |
""" |
| 266 |
dvdwriter = DvdWriter("/dev/dvd", scsiId="ATA:1,0,0", unittest=True) |
| 267 |
self.assertEqual("/dev/dvd", dvdwriter.device) |
| 268 |
self.assertEqual("ATA:1,0,0", dvdwriter.scsiId) |
| 269 |
self.assertEqual("/dev/dvd", dvdwriter.hardwareId) |
| 270 |
self.assertEqual(None, dvdwriter.driveSpeed) |
| 271 |
self.assertEqual(MEDIA_DVDPLUSRW, dvdwriter.media.mediaType) |
| 272 |
self.assertEqual(True, dvdwriter.deviceHasTray) |
| 273 |
self.assertEqual(True, dvdwriter.deviceCanEject) |
| 274 |
|
| 275 |
def testConstructor_004(self): |
| 276 |
""" |
| 277 |
Test with a device and valid drive speed. |
| 278 |
""" |
| 279 |
dvdwriter = DvdWriter("/dev/dvd", driveSpeed=3, unittest=True) |
| 280 |
self.assertEqual("/dev/dvd", dvdwriter.device) |
| 281 |
self.assertEqual(None, dvdwriter.scsiId) |
| 282 |
self.assertEqual("/dev/dvd", dvdwriter.hardwareId) |
| 283 |
self.assertEqual(3, dvdwriter.driveSpeed) |
| 284 |
self.assertEqual(MEDIA_DVDPLUSRW, dvdwriter.media.mediaType) |
| 285 |
self.assertEqual(True, dvdwriter.deviceHasTray) |
| 286 |
self.assertEqual(True, dvdwriter.deviceCanEject) |
| 287 |
|
| 288 |
def testConstructor_005(self): |
| 289 |
""" |
| 290 |
Test with a device with media type MEDIA_DVDPLUSR. |
| 291 |
""" |
| 292 |
dvdwriter = DvdWriter("/dev/dvd", mediaType=MEDIA_DVDPLUSR, unittest=True) |
| 293 |
self.assertEqual("/dev/dvd", dvdwriter.device) |
| 294 |
self.assertEqual(None, dvdwriter.scsiId) |
| 295 |
self.assertEqual("/dev/dvd", dvdwriter.hardwareId) |
| 296 |
self.assertEqual(None, dvdwriter.driveSpeed) |
| 297 |
self.assertEqual(MEDIA_DVDPLUSR, dvdwriter.media.mediaType) |
| 298 |
self.assertEqual(True, dvdwriter.deviceHasTray) |
| 299 |
self.assertEqual(True, dvdwriter.deviceCanEject) |
| 300 |
|
| 301 |
def testConstructor_006(self): |
| 302 |
""" |
| 303 |
Test with a device with media type MEDIA_DVDPLUSRW. |
| 304 |
""" |
| 305 |
dvdwriter = DvdWriter("/dev/dvd", mediaType=MEDIA_DVDPLUSR, unittest=True) |
| 306 |
self.assertEqual("/dev/dvd", dvdwriter.device) |
| 307 |
self.assertEqual(None, dvdwriter.scsiId) |
| 308 |
self.assertEqual("/dev/dvd", dvdwriter.hardwareId) |
| 309 |
self.assertEqual(None, dvdwriter.driveSpeed) |
| 310 |
self.assertEqual(MEDIA_DVDPLUSR, dvdwriter.media.mediaType) |
| 311 |
self.assertEqual(True, dvdwriter.deviceHasTray) |
| 312 |
self.assertEqual(True, dvdwriter.deviceCanEject) |
| 313 |
|
| 314 |
def testConstructor_007(self): |
| 315 |
""" |
| 316 |
Test with a device and invalid SCSI id. |
| 317 |
""" |
| 318 |
dvdwriter = DvdWriter("/dev/dvd", scsiId="00000000", unittest=True) |
| 319 |
self.assertEqual("/dev/dvd", dvdwriter.device) |
| 320 |
self.assertEqual("00000000", dvdwriter.scsiId) |
| 321 |
self.assertEqual("/dev/dvd", dvdwriter.hardwareId) |
| 322 |
self.assertEqual(None, dvdwriter.driveSpeed) |
| 323 |
self.assertEqual(MEDIA_DVDPLUSRW, dvdwriter.media.mediaType) |
| 324 |
self.assertEqual(True, dvdwriter.deviceHasTray) |
| 325 |
self.assertEqual(True, dvdwriter.deviceCanEject) |
| 326 |
|
| 327 |
def testConstructor_008(self): |
| 328 |
""" |
| 329 |
Test with a device and invalid drive speed. |
| 330 |
""" |
| 331 |
self.assertRaises(ValueError, DvdWriter, "/dev/dvd", driveSpeed="KEN", unittest=True) |
| 332 |
|
| 333 |
def testConstructor_009(self): |
| 334 |
""" |
| 335 |
Test with a device and invalid media type. |
| 336 |
""" |
| 337 |
self.assertRaises(ValueError, DvdWriter, "/dev/dvd", mediaType=999, unittest=True) |
| 338 |
|
| 339 |
def testConstructor_010(self): |
| 340 |
""" |
| 341 |
Test with all valid parameters, but no device, unittest=True. |
| 342 |
""" |
| 343 |
self.assertRaises(ValueError, DvdWriter, None, "ATA:1,0,0", 1, MEDIA_DVDPLUSRW, unittest=True) |
| 344 |
|
| 345 |
def testConstructor_011(self): |
| 346 |
""" |
| 347 |
Test with all valid parameters, but no device, unittest=False. |
| 348 |
""" |
| 349 |
self.assertRaises(ValueError, DvdWriter, None, "ATA:1,0,0", 1, MEDIA_DVDPLUSRW, unittest=False) |
| 350 |
|
| 351 |
def testConstructor_012(self): |
| 352 |
""" |
| 353 |
Test with all valid parameters, and an invalid device (not absolute path), unittest=True. |
| 354 |
""" |
| 355 |
self.assertRaises(ValueError, DvdWriter, "dev/dvd", "ATA:1,0,0", 1, MEDIA_DVDPLUSRW, unittest=True) |
| 356 |
|
| 357 |
def testConstructor_013(self): |
| 358 |
""" |
| 359 |
Test with all valid parameters, and an invalid device (not absolute path), unittest=False. |
| 360 |
""" |
| 361 |
self.assertRaises(ValueError, DvdWriter, "dev/dvd", "ATA:1,0,0", 1, MEDIA_DVDPLUSRW, unittest=False) |
| 362 |
|
| 363 |
def testConstructor_014(self): |
| 364 |
""" |
| 365 |
Test with all valid parameters, and an invalid device (path does not exist), unittest=False. |
| 366 |
""" |
| 367 |
self.assertRaises(ValueError, DvdWriter, "/dev/bogus", "ATA:1,0,0", 1, MEDIA_DVDPLUSRW, unittest=False) |
| 368 |
|
| 369 |
def testConstructor_015(self): |
| 370 |
""" |
| 371 |
Test with all valid parameters. |
| 372 |
""" |
| 373 |
dvdwriter = DvdWriter("/dev/dvd", "ATA:1,0,0", 1, MEDIA_DVDPLUSR, noEject=False, unittest=True) |
| 374 |
self.assertEqual("/dev/dvd", dvdwriter.device) |
| 375 |
self.assertEqual("ATA:1,0,0", dvdwriter.scsiId) |
| 376 |
self.assertEqual("/dev/dvd", dvdwriter.hardwareId) |
| 377 |
self.assertEqual(1, dvdwriter.driveSpeed) |
| 378 |
self.assertEqual(MEDIA_DVDPLUSR, dvdwriter.media.mediaType) |
| 379 |
self.assertEqual(True, dvdwriter.deviceHasTray) |
| 380 |
self.assertEqual(True, dvdwriter.deviceCanEject) |
| 381 |
|
| 382 |
def testConstructor_016(self): |
| 383 |
""" |
| 384 |
Test with all valid parameters. |
| 385 |
""" |
| 386 |
dvdwriter = DvdWriter("/dev/dvd", "ATA:1,0,0", 1, MEDIA_DVDPLUSR, noEject=True, unittest=True) |
| 387 |
self.assertEqual("/dev/dvd", dvdwriter.device) |
| 388 |
self.assertEqual("ATA:1,0,0", dvdwriter.scsiId) |
| 389 |
self.assertEqual("/dev/dvd", dvdwriter.hardwareId) |
| 390 |
self.assertEqual(1, dvdwriter.driveSpeed) |
| 391 |
self.assertEqual(MEDIA_DVDPLUSR, dvdwriter.media.mediaType) |
| 392 |
self.assertEqual(False, dvdwriter.deviceHasTray) |
| 393 |
self.assertEqual(False, dvdwriter.deviceCanEject) |
| 394 |
|
| 395 |
###################### |
| 396 |
# Test isRewritable() |
| 397 |
###################### |
| 398 |
|
| 399 |
def testIsRewritable_001(self): |
| 400 |
""" |
| 401 |
Test with MEDIA_DVDPLUSR. |
| 402 |
""" |
| 403 |
dvdwriter = DvdWriter("/dev/dvd", mediaType=MEDIA_DVDPLUSR, unittest=True) |
| 404 |
self.assertEqual(False, dvdwriter.isRewritable()) |
| 405 |
|
| 406 |
def testIsRewritable_002(self): |
| 407 |
""" |
| 408 |
Test with MEDIA_DVDPLUSRW. |
| 409 |
""" |
| 410 |
dvdwriter = DvdWriter("/dev/dvd", mediaType=MEDIA_DVDPLUSRW, unittest=True) |
| 411 |
self.assertEqual(True, dvdwriter.isRewritable()) |
| 412 |
|
| 413 |
######################### |
| 414 |
# Test initializeImage() |
| 415 |
######################### |
| 416 |
|
| 417 |
def testInitializeImage_001(self): |
| 418 |
""" |
| 419 |
Test with newDisc=False, tmpdir=None. |
| 420 |
""" |
| 421 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 422 |
dvdwriter.initializeImage(False, None) |
| 423 |
self.assertEqual(False, dvdwriter._image.newDisc) |
| 424 |
self.assertEqual(None, dvdwriter._image.tmpdir) |
| 425 |
self.assertEqual({}, dvdwriter._image.entries) |
| 426 |
|
| 427 |
def testInitializeImage_002(self): |
| 428 |
""" |
| 429 |
Test with newDisc=True, tmpdir not None. |
| 430 |
""" |
| 431 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 432 |
dvdwriter.initializeImage(True, "/path/to/somewhere") |
| 433 |
self.assertEqual(True, dvdwriter._image.newDisc) |
| 434 |
self.assertEqual("/path/to/somewhere", dvdwriter._image.tmpdir) |
| 435 |
self.assertEqual({}, dvdwriter._image.entries) |
| 436 |
|
| 437 |
####################### |
| 438 |
# Test addImageEntry() |
| 439 |
####################### |
| 440 |
|
| 441 |
def testAddImageEntry_001(self): |
| 442 |
""" |
| 443 |
Add a valid path with no graft point, before calling initializeImage(). |
| 444 |
""" |
| 445 |
self.extractTar("tree9") |
| 446 |
path = self.buildPath(["tree9", "dir002"]) |
| 447 |
self.assertTrue(os.path.exists(path)) |
| 448 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 449 |
self.assertRaises(ValueError, dvdwriter.addImageEntry, path, None) |
| 450 |
|
| 451 |
def testAddImageEntry_002(self): |
| 452 |
""" |
| 453 |
Add a valid path with a graft point, before calling initializeImage(). |
| 454 |
""" |
| 455 |
self.extractTar("tree9") |
| 456 |
path = self.buildPath(["tree9", "dir002"]) |
| 457 |
self.assertTrue(os.path.exists(path)) |
| 458 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 459 |
self.assertRaises(ValueError, dvdwriter.addImageEntry, path, "ken") |
| 460 |
|
| 461 |
def testAddImageEntry_003(self): |
| 462 |
""" |
| 463 |
Add a non-existent path with no graft point, before calling initializeImage(). |
| 464 |
""" |
| 465 |
self.extractTar("tree9") |
| 466 |
path = self.buildPath(["tree9", "bogus"]) |
| 467 |
self.assertFalse(os.path.exists(path)) |
| 468 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 469 |
self.assertRaises(ValueError, dvdwriter.addImageEntry, path, None) |
| 470 |
|
| 471 |
def testAddImageEntry_004(self): |
| 472 |
""" |
| 473 |
Add a non-existent path with a graft point, before calling initializeImage(). |
| 474 |
""" |
| 475 |
self.extractTar("tree9") |
| 476 |
path = self.buildPath(["tree9", "bogus"]) |
| 477 |
self.assertFalse(os.path.exists(path)) |
| 478 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 479 |
self.assertRaises(ValueError, dvdwriter.addImageEntry, path, "ken") |
| 480 |
|
| 481 |
def testAddImageEntry_005(self): |
| 482 |
""" |
| 483 |
Add a valid path with no graft point, after calling initializeImage(). |
| 484 |
""" |
| 485 |
self.extractTar("tree9") |
| 486 |
path = self.buildPath(["tree9", "dir002"]) |
| 487 |
self.assertTrue(os.path.exists(path)) |
| 488 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 489 |
dvdwriter.initializeImage(False, None) |
| 490 |
dvdwriter.addImageEntry(path, None) |
| 491 |
self.assertEqual({path: None}, dvdwriter._image.entries) |
| 492 |
|
| 493 |
def testAddImageEntry_006(self): |
| 494 |
""" |
| 495 |
Add a valid path with a graft point, after calling initializeImage(). |
| 496 |
""" |
| 497 |
self.extractTar("tree9") |
| 498 |
path = self.buildPath(["tree9", "dir002"]) |
| 499 |
self.assertTrue(os.path.exists(path)) |
| 500 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 501 |
dvdwriter.initializeImage(False, None) |
| 502 |
dvdwriter.addImageEntry(path, "ken") |
| 503 |
self.assertEqual({path: "ken"}, dvdwriter._image.entries) |
| 504 |
|
| 505 |
def testAddImageEntry_007(self): |
| 506 |
""" |
| 507 |
Add a non-existent path with no graft point, after calling initializeImage(). |
| 508 |
""" |
| 509 |
self.extractTar("tree9") |
| 510 |
path = self.buildPath(["tree9", "bogus"]) |
| 511 |
self.assertFalse(os.path.exists(path)) |
| 512 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 513 |
dvdwriter.initializeImage(False, None) |
| 514 |
self.assertRaises(ValueError, dvdwriter.addImageEntry, path, None) |
| 515 |
|
| 516 |
def testAddImageEntry_008(self): |
| 517 |
""" |
| 518 |
Add a non-existent path with a graft point, after calling initializeImage(). |
| 519 |
""" |
| 520 |
self.extractTar("tree9") |
| 521 |
path = self.buildPath(["tree9", "bogus"]) |
| 522 |
self.assertFalse(os.path.exists(path)) |
| 523 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 524 |
dvdwriter.initializeImage(False, None) |
| 525 |
self.assertRaises(ValueError, dvdwriter.addImageEntry, path, "ken") |
| 526 |
|
| 527 |
def testAddImageEntry_009(self): |
| 528 |
""" |
| 529 |
Add the same path several times. |
| 530 |
""" |
| 531 |
self.extractTar("tree9") |
| 532 |
path = self.buildPath(["tree9", "dir002"]) |
| 533 |
self.assertTrue(os.path.exists(path)) |
| 534 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 535 |
dvdwriter.initializeImage(False, None) |
| 536 |
dvdwriter.addImageEntry(path, "ken") |
| 537 |
self.assertEqual({path: "ken"}, dvdwriter._image.entries) |
| 538 |
dvdwriter.addImageEntry(path, "ken") |
| 539 |
self.assertEqual({path: "ken"}, dvdwriter._image.entries) |
| 540 |
dvdwriter.addImageEntry(path, "ken") |
| 541 |
self.assertEqual({path: "ken"}, dvdwriter._image.entries) |
| 542 |
dvdwriter.addImageEntry(path, "ken") |
| 543 |
self.assertEqual({path: "ken"}, dvdwriter._image.entries) |
| 544 |
|
| 545 |
def testAddImageEntry_010(self): |
| 546 |
""" |
| 547 |
Add several paths. |
| 548 |
""" |
| 549 |
self.extractTar("tree9") |
| 550 |
path1 = self.buildPath(["tree9", "dir001"]) |
| 551 |
path2 = self.buildPath(["tree9", "dir002"]) |
| 552 |
path3 = self.buildPath(["tree9", "dir001", "dir001"]) |
| 553 |
self.assertTrue(os.path.exists(path1)) |
| 554 |
self.assertTrue(os.path.exists(path2)) |
| 555 |
self.assertTrue(os.path.exists(path3)) |
| 556 |
dvdwriter = DvdWriter("/dev/dvd", unittest=True) |
| 557 |
dvdwriter.initializeImage(False, None) |
| 558 |
dvdwriter.addImageEntry(path1, None) |
| 559 |
self.assertEqual({path1: None}, dvdwriter._image.entries) |
| 560 |
dvdwriter.addImageEntry(path2, "ken") |
| 561 |
self.assertEqual({path1: None, path2: "ken"}, dvdwriter._image.entries) |
| 562 |
dvdwriter.addImageEntry(path3, "another") |
| 563 |
self.assertEqual({path1: None, path2: "ken", path3: "another"}, dvdwriter._image.entries) |
| 564 |
|
| 565 |
############################ |
| 566 |
# Test _searchForOverburn() |
| 567 |
############################ |
| 568 |
|
| 569 |
def testSearchForOverburn_001(self): |
| 570 |
""" |
| 571 |
Test with output=None. |
| 572 |
""" |
| 573 |
output = None |
| 574 |
DvdWriter._searchForOverburn(output) # no exception should be thrown |
| 575 |
|
| 576 |
def testSearchForOverburn_002(self): |
| 577 |
""" |
| 578 |
Test with output=[]. |
| 579 |
""" |
| 580 |
output = [] |
| 581 |
DvdWriter._searchForOverburn(output) # no exception should be thrown |
| 582 |
|
| 583 |
def testSearchForOverburn_003(self): |
| 584 |
""" |
| 585 |
Test with one-line output, not containing the pattern. |
| 586 |
""" |
| 587 |
output = [ |
| 588 |
"This line does not contain the pattern", |
| 589 |
] |
| 590 |
DvdWriter._searchForOverburn(output) # no exception should be thrown |
| 591 |
output = [ |
| 592 |
":-( /dev/cdrom: blocks are free, to be written!", |
| 593 |
] |
| 594 |
DvdWriter._searchForOverburn(output) # no exception should be thrown |
| 595 |
output = [ |
| 596 |
":-) /dev/cdrom: 89048 blocks are free, 2033746 to be written!", |
| 597 |
] |
| 598 |
DvdWriter._searchForOverburn(output) # no exception should be thrown |
| 599 |
output = [ |
| 600 |
":-( /dev/cdrom: 894048blocks are free, 2033746to be written!", |
| 601 |
] |
| 602 |
DvdWriter._searchForOverburn(output) # no exception should be thrown |
| 603 |
|
| 604 |
def testSearchForOverburn_004(self): |
| 605 |
""" |
| 606 |
Test with one-line output(s), containing the pattern. |
| 607 |
""" |
| 608 |
output = [ |
| 609 |
":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!", |
| 610 |
] |
| 611 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 612 |
output = [ |
| 613 |
":-( /dev/cdrom: XXXX blocks are free, XXXX to be written!", |
| 614 |
] |
| 615 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 616 |
output = [ |
| 617 |
":-( /dev/cdrom: 1 blocks are free, 1 to be written!", |
| 618 |
] |
| 619 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 620 |
output = [ |
| 621 |
":-( /dev/cdrom: 0 blocks are free, 0 to be written!", |
| 622 |
] |
| 623 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 624 |
output = [ |
| 625 |
":-( /dev/dvd: 0 blocks are free, 0 to be written!", |
| 626 |
] |
| 627 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 628 |
output = [ |
| 629 |
":-( /dev/writer: 0 blocks are free, 0 to be written!", |
| 630 |
] |
| 631 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 632 |
output = [ |
| 633 |
":-( bogus: 0 blocks are free, 0 to be written!", |
| 634 |
] |
| 635 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 636 |
|
| 637 |
def testSearchForOverburn_005(self): |
| 638 |
""" |
| 639 |
Test with multi-line output, not containing the pattern. |
| 640 |
""" |
| 641 |
output = [] |
| 642 |
output.append( |
| 643 |
"Executing 'mkisofs -C 973744,1401056 -M /dev/fd/3 -r -graft-points music4/=music | builtin_dd of=/dev/cdrom obs=32k seek=87566'" |
| 644 |
) |
| 645 |
output.append("Rock Ridge signatures found") |
| 646 |
output.append("Using THE_K000 for music4/The_Kings_Singers (The_Kingston_Trio)") |
| 647 |
output.append( |
| 648 |
"Using COCKT000 for music/Various_Artists/Cocktail_Classics_-_Beethovens_Fifth_and_Others (Cocktail_Classics_-_Pachelbels_Canon_and_Others)" |
| 649 |
) |
| 650 |
output.append( |
| 651 |
"Using THE_V000 for music/Brahms/The_Violin_Sonatas (The_Viola_Sonatas) Using COMPL000 for music/Gershwin/Complete_Gershwin_2 (Complete_Gershwin_1)" |
| 652 |
) |
| 653 |
output.append( |
| 654 |
"Using SELEC000.MP3;1 for music/Marquette_Chorus/Selected_Christmas_Carols_For_Double_Choir.mp3 (Selected_Choruses_from_The_Lark.mp3)" |
| 655 |
) |
| 656 |
output.append( |
| 657 |
"Using SELEC001.MP3;1 for music/Marquette_Chorus/Selected_Choruses_from_The_Lark.mp3 (Selected_Choruses_from_Messiah.mp3)" |
| 658 |
) |
| 659 |
output.append( |
| 660 |
"Using IN_TH000.MP3;1 for music/Marquette_Chorus/In_the_Bleak_Midwinter.mp3 (In_the_Beginning.mp3) Using AFRIC000.MP3;1 for music/Marquette_Chorus/African_Noel-tb.mp3 (African_Noel-satb.mp3)" |
| 661 |
) |
| 662 |
DvdWriter._searchForOverburn(output) # no exception should be thrown") |
| 663 |
|
| 664 |
def testSearchForOverburn_006(self): |
| 665 |
""" |
| 666 |
Test with multi-line output, containing the pattern at the top. |
| 667 |
""" |
| 668 |
output = [] |
| 669 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 670 |
output.append( |
| 671 |
"Executing 'mkisofs -C 973744,1401056 -M /dev/fd/3 -r -graft-points music4/=music | builtin_dd of=/dev/cdrom obs=32k seek=87566'" |
| 672 |
) |
| 673 |
output.append("Rock Ridge signatures found") |
| 674 |
output.append("Using THE_K000 for music4/The_Kings_Singers (The_Kingston_Trio)") |
| 675 |
output.append( |
| 676 |
"Using COCKT000 for music/Various_Artists/Cocktail_Classics_-_Beethovens_Fifth_and_Others (Cocktail_Classics_-_Pachelbels_Canon_and_Others)" |
| 677 |
) |
| 678 |
output.append( |
| 679 |
"Using THE_V000 for music/Brahms/The_Violin_Sonatas (The_Viola_Sonatas) Using COMPL000 for music/Gershwin/Complete_Gershwin_2 (Complete_Gershwin_1)" |
| 680 |
) |
| 681 |
output.append( |
| 682 |
"Using SELEC000.MP3;1 for music/Marquette_Chorus/Selected_Christmas_Carols_For_Double_Choir.mp3 (Selected_Choruses_from_The_Lark.mp3)" |
| 683 |
) |
| 684 |
output.append( |
| 685 |
"Using SELEC001.MP3;1 for music/Marquette_Chorus/Selected_Choruses_from_The_Lark.mp3 (Selected_Choruses_from_Messiah.mp3)" |
| 686 |
) |
| 687 |
output.append( |
| 688 |
"Using IN_TH000.MP3;1 for music/Marquette_Chorus/In_the_Bleak_Midwinter.mp3 (In_the_Beginning.mp3) Using AFRIC000.MP3;1 for music/Marquette_Chorus/African_Noel-tb.mp3 (African_Noel-satb.mp3)" |
| 689 |
) |
| 690 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 691 |
|
| 692 |
def testSearchForOverburn_007(self): |
| 693 |
""" |
| 694 |
Test with multi-line output, containing the pattern at the bottom. |
| 695 |
""" |
| 696 |
output = [] |
| 697 |
output.append( |
| 698 |
"Executing 'mkisofs -C 973744,1401056 -M /dev/fd/3 -r -graft-points music4/=music | builtin_dd of=/dev/cdrom obs=32k seek=87566'" |
| 699 |
) |
| 700 |
output.append("Rock Ridge signatures found") |
| 701 |
output.append("Using THE_K000 for music4/The_Kings_Singers (The_Kingston_Trio)") |
| 702 |
output.append( |
| 703 |
"Using COCKT000 for music/Various_Artists/Cocktail_Classics_-_Beethovens_Fifth_and_Others (Cocktail_Classics_-_Pachelbels_Canon_and_Others)" |
| 704 |
) |
| 705 |
output.append( |
| 706 |
"Using THE_V000 for music/Brahms/The_Violin_Sonatas (The_Viola_Sonatas) Using COMPL000 for music/Gershwin/Complete_Gershwin_2 (Complete_Gershwin_1)" |
| 707 |
) |
| 708 |
output.append( |
| 709 |
"Using SELEC000.MP3;1 for music/Marquette_Chorus/Selected_Christmas_Carols_For_Double_Choir.mp3 (Selected_Choruses_from_The_Lark.mp3)" |
| 710 |
) |
| 711 |
output.append( |
| 712 |
"Using SELEC001.MP3;1 for music/Marquette_Chorus/Selected_Choruses_from_The_Lark.mp3 (Selected_Choruses_from_Messiah.mp3)" |
| 713 |
) |
| 714 |
output.append( |
| 715 |
"Using IN_TH000.MP3;1 for music/Marquette_Chorus/In_the_Bleak_Midwinter.mp3 (In_the_Beginning.mp3) Using AFRIC000.MP3;1 for music/Marquette_Chorus/African_Noel-tb.mp3 (African_Noel-satb.mp3)" |
| 716 |
) |
| 717 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 718 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 719 |
|
| 720 |
def testSearchForOverburn_008(self): |
| 721 |
""" |
| 722 |
Test with multi-line output, containing the pattern in the middle. |
| 723 |
""" |
| 724 |
output = [] |
| 725 |
output.append( |
| 726 |
"Executing 'mkisofs -C 973744,1401056 -M /dev/fd/3 -r -graft-points music4/=music | builtin_dd of=/dev/cdrom obs=32k seek=87566'" |
| 727 |
) |
| 728 |
output.append("Rock Ridge signatures found") |
| 729 |
output.append("Using THE_K000 for music4/The_Kings_Singers (The_Kingston_Trio)") |
| 730 |
output.append( |
| 731 |
"Using COCKT000 for music/Various_Artists/Cocktail_Classics_-_Beethovens_Fifth_and_Others (Cocktail_Classics_-_Pachelbels_Canon_and_Others)" |
| 732 |
) |
| 733 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 734 |
output.append( |
| 735 |
"Using THE_V000 for music/Brahms/The_Violin_Sonatas (The_Viola_Sonatas) Using COMPL000 for music/Gershwin/Complete_Gershwin_2 (Complete_Gershwin_1)" |
| 736 |
) |
| 737 |
output.append( |
| 738 |
"Using SELEC000.MP3;1 for music/Marquette_Chorus/Selected_Christmas_Carols_For_Double_Choir.mp3 (Selected_Choruses_from_The_Lark.mp3)" |
| 739 |
) |
| 740 |
output.append( |
| 741 |
"Using SELEC001.MP3;1 for music/Marquette_Chorus/Selected_Choruses_from_The_Lark.mp3 (Selected_Choruses_from_Messiah.mp3)" |
| 742 |
) |
| 743 |
output.append( |
| 744 |
"Using IN_TH000.MP3;1 for music/Marquette_Chorus/In_the_Bleak_Midwinter.mp3 (In_the_Beginning.mp3) Using AFRIC000.MP3;1 for music/Marquette_Chorus/African_Noel-tb.mp3 (African_Noel-satb.mp3)" |
| 745 |
) |
| 746 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 747 |
|
| 748 |
def testSearchForOverburn_009(self): |
| 749 |
""" |
| 750 |
Test with multi-line output, containing the pattern several times. |
| 751 |
""" |
| 752 |
output = [] |
| 753 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 754 |
output.append( |
| 755 |
"Executing 'mkisofs -C 973744,1401056 -M /dev/fd/3 -r -graft-points music4/=music | builtin_dd of=/dev/cdrom obs=32k seek=87566'" |
| 756 |
) |
| 757 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 758 |
output.append("Rock Ridge signatures found") |
| 759 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 760 |
output.append("Using THE_K000 for music4/The_Kings_Singers (The_Kingston_Trio)") |
| 761 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 762 |
output.append( |
| 763 |
"Using COCKT000 for music/Various_Artists/Cocktail_Classics_-_Beethovens_Fifth_and_Others (Cocktail_Classics_-_Pachelbels_Canon_and_Others)" |
| 764 |
) |
| 765 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 766 |
output.append( |
| 767 |
"Using THE_V000 for music/Brahms/The_Violin_Sonatas (The_Viola_Sonatas) Using COMPL000 for music/Gershwin/Complete_Gershwin_2 (Complete_Gershwin_1)" |
| 768 |
) |
| 769 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 770 |
output.append( |
| 771 |
"Using SELEC000.MP3;1 for music/Marquette_Chorus/Selected_Christmas_Carols_For_Double_Choir.mp3 (Selected_Choruses_from_The_Lark.mp3)" |
| 772 |
) |
| 773 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 774 |
output.append( |
| 775 |
"Using SELEC001.MP3;1 for music/Marquette_Chorus/Selected_Choruses_from_The_Lark.mp3 (Selected_Choruses_from_Messiah.mp3)" |
| 776 |
) |
| 777 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 778 |
output.append( |
| 779 |
"Using IN_TH000.MP3;1 for music/Marquette_Chorus/In_the_Bleak_Midwinter.mp3 (In_the_Beginning.mp3) Using AFRIC000.MP3;1 for music/Marquette_Chorus/African_Noel-tb.mp3 (African_Noel-satb.mp3)" |
| 780 |
) |
| 781 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 782 |
output.append(":-( /dev/cdrom: 894048 blocks are free, 2033746 to be written!") |
| 783 |
self.assertRaises(IOError, DvdWriter._searchForOverburn, output) |
| 784 |
|
| 785 |
########################### |
| 786 |
# Test _parseSectorsUsed() |
| 787 |
########################### |
| 788 |
|
| 789 |
def testParseSectorsUsed_001(self): |
| 790 |
""" |
| 791 |
Test with output=None. |
| 792 |
""" |
| 793 |
output = None |
| 794 |
sectorsUsed = DvdWriter._parseSectorsUsed(output) |
| 795 |
self.assertEqual(0.0, sectorsUsed) |
| 796 |
|
| 797 |
def testParseSectorsUsed_002(self): |
| 798 |
""" |
| 799 |
Test with output=[]. |
| 800 |
""" |
| 801 |
output = [] |
| 802 |
sectorsUsed = DvdWriter._parseSectorsUsed(output) |
| 803 |
self.assertEqual(0.0, sectorsUsed) |
| 804 |
|
| 805 |
def testParseSectorsUsed_003(self): |
| 806 |
""" |
| 807 |
Test with one-line output, not containing the pattern. |
| 808 |
""" |
| 809 |
output = [ |
| 810 |
"This line does not contain the pattern", |
| 811 |
] |
| 812 |
sectorsUsed = DvdWriter._parseSectorsUsed(output) |
| 813 |
self.assertEqual(0.0, sectorsUsed) |
| 814 |
|
| 815 |
def testParseSectorsUsed_004(self): |
| 816 |
""" |
| 817 |
Test with one-line output(s), containing the pattern. |
| 818 |
""" |
| 819 |
output = [ |
| 820 |
"'seek=10'", |
| 821 |
] |
| 822 |
sectorsUsed = DvdWriter._parseSectorsUsed(output) |
| 823 |
self.assertEqual(10.0 * 16.0, sectorsUsed) |
| 824 |
|
| 825 |
output = [ |
| 826 |
"' seek= 10 '", |
| 827 |
] |
| 828 |
sectorsUsed = DvdWriter._parseSectorsUsed(output) |
| 829 |
self.assertEqual(10.0 * 16.0, sectorsUsed) |
| 830 |
|
| 831 |
output = [ |
| 832 |
"Executing 'mkisofs -C 973744,1401056 -M /dev/fd/3 -r -graft-points music4/=music | builtin_dd of=/dev/cdrom obs=32k seek=87566'", |
| 833 |
] |
| 834 |
sectorsUsed = DvdWriter._parseSectorsUsed(output) |
| 835 |
self.assertEqual(87566 * 16.0, sectorsUsed) |
| 836 |
|
| 837 |
def testParseSectorsUsed_005(self): |
| 838 |
""" |
| 839 |
Test with real growisofs output. |
| 840 |
""" |
| 841 |
output = [] |
| 842 |
output.append( |
| 843 |
"Executing 'mkisofs -C 973744,1401056 -M /dev/fd/3 -r -graft-points music4/=music | builtin_dd of=/dev/cdrom obs=32k seek=87566'" |
| 844 |
) |
| 845 |
output.append("Rock Ridge signatures found") |
| 846 |
output.append("Using THE_K000 for music4/The_Kings_Singers (The_Kingston_Trio)") |
| 847 |
output.append( |
| 848 |
"Using COCKT000 for music/Various_Artists/Cocktail_Classics_-_Beethovens_Fifth_and_Others (Cocktail_Classics_-_Pachelbels_Canon_and_Others)" |
| 849 |
) |
| 850 |
output.append( |
| 851 |
"Using THE_V000 for music/Brahms/The_Violin_Sonatas (The_Viola_Sonatas) Using COMPL000 for music/Gershwin/Complete_Gershwin_2 (Complete_Gershwin_1)" |
| 852 |
) |
| 853 |
output.append( |
| 854 |
"Using SELEC000.MP3;1 for music/Marquette_Chorus/Selected_Christmas_Carols_For_Double_Choir.mp3 (Selected_Choruses_from_The_Lark.mp3)" |
| 855 |
) |
| 856 |
output.append( |
| 857 |
"Using SELEC001.MP3;1 for music/Marquette_Chorus/Selected_Choruses_from_The_Lark.mp3 (Selected_Choruses_from_Messiah.mp3)" |
| 858 |
) |
| 859 |
output.append( |
| 860 |
"Using IN_TH000.MP3;1 for music/Marquette_Chorus/In_the_Bleak_Midwinter.mp3 (In_the_Beginning.mp3) Using AFRIC000.MP3;1 for music/Marquette_Chorus/African_Noel-tb.mp3 (African_Noel-satb.mp3)" |
| 861 |
) |
| 862 |
sectorsUsed = DvdWriter._parseSectorsUsed(output) |
| 863 |
self.assertEqual(87566 * 16.0, sectorsUsed) |
| 864 |
|
| 865 |
######################### |
| 866 |
# Test _buildWriteArgs() |
| 867 |
######################### |
| 868 |
|
| 869 |
def testBuildWriteArgs_001(self): |
| 870 |
""" |
| 871 |
Test with newDisc=False, hardwareId="/dev/dvd", driveSpeed=None, |
| 872 |
imagePath=None, entries=None, mediaLabel=None,dryRun=False. |
| 873 |
""" |
| 874 |
newDisc = False |
| 875 |
hardwareId = "/dev/dvd" |
| 876 |
driveSpeed = None |
| 877 |
imagePath = None |
| 878 |
entries = None |
| 879 |
mediaLabel = None |
| 880 |
dryRun = False |
| 881 |
self.assertRaises( |
| 882 |
ValueError, DvdWriter._buildWriteArgs, newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun |
| 883 |
) |
| 884 |
|
| 885 |
def testBuildWriteArgs_002(self): |
| 886 |
""" |
| 887 |
Test with newDisc=False, hardwareId="/dev/dvd", driveSpeed=None, |
| 888 |
imagePath=None, entries=None, mediaLabel=None, dryRun=True. |
| 889 |
""" |
| 890 |
newDisc = False |
| 891 |
hardwareId = "/dev/dvd" |
| 892 |
driveSpeed = None |
| 893 |
imagePath = None |
| 894 |
entries = None |
| 895 |
mediaLabel = None |
| 896 |
dryRun = True |
| 897 |
self.assertRaises( |
| 898 |
ValueError, DvdWriter._buildWriteArgs, newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun |
| 899 |
) |
| 900 |
|
| 901 |
def testBuildWriteArgs_003(self): |
| 902 |
""" |
| 903 |
Test with newDisc=False, hardwareId="/dev/dvd", driveSpeed=None, |
| 904 |
imagePath="/path/to/image", entries=None, mediaLabel=None, dryRun=False. |
| 905 |
""" |
| 906 |
newDisc = False |
| 907 |
hardwareId = "/dev/dvd" |
| 908 |
driveSpeed = None |
| 909 |
imagePath = "/path/to/image" |
| 910 |
entries = None |
| 911 |
mediaLabel = None |
| 912 |
dryRun = False |
| 913 |
expected = [ |
| 914 |
"-use-the-force-luke=tty", |
| 915 |
"-M", |
| 916 |
"/dev/dvd=/path/to/image", |
| 917 |
] |
| 918 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 919 |
self.assertEqual(actual, expected) |
| 920 |
|
| 921 |
def testBuildWriteArgs_004(self): |
| 922 |
""" |
| 923 |
Test with newDisc=False, hardwareId="/dev/dvd", driveSpeed=None, |
| 924 |
imagePath="/path/to/image", entries=None, mediaLabel=None, dryRun=True. |
| 925 |
""" |
| 926 |
newDisc = False |
| 927 |
hardwareId = "/dev/dvd" |
| 928 |
driveSpeed = None |
| 929 |
imagePath = "/path/to/image" |
| 930 |
entries = None |
| 931 |
mediaLabel = None |
| 932 |
dryRun = True |
| 933 |
expected = [ |
| 934 |
"-use-the-force-luke=tty", |
| 935 |
"-dry-run", |
| 936 |
"-M", |
| 937 |
"/dev/dvd=/path/to/image", |
| 938 |
] |
| 939 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 940 |
self.assertEqual(actual, expected) |
| 941 |
|
| 942 |
def testBuildWriteArgs_005(self): |
| 943 |
""" |
| 944 |
Test with newDisc=True, hardwareId="/dev/dvd", driveSpeed=None, |
| 945 |
imagePath="/path/to/image", entries=None, mediaLabel=None, dryRun=False. |
| 946 |
""" |
| 947 |
newDisc = True |
| 948 |
hardwareId = "/dev/dvd" |
| 949 |
driveSpeed = None |
| 950 |
imagePath = "/path/to/image" |
| 951 |
entries = None |
| 952 |
mediaLabel = None |
| 953 |
dryRun = False |
| 954 |
expected = [ |
| 955 |
"-use-the-force-luke=tty", |
| 956 |
"-Z", |
| 957 |
"/dev/dvd=/path/to/image", |
| 958 |
] |
| 959 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 960 |
self.assertEqual(actual, expected) |
| 961 |
|
| 962 |
def testBuildWriteArgs_006(self): |
| 963 |
""" |
| 964 |
Test with newDisc=True, hardwareId="/dev/dvd", driveSpeed=None, |
| 965 |
imagePath="/path/to/image", entries=None, mediaLabel=None, dryRun=True. |
| 966 |
""" |
| 967 |
newDisc = True |
| 968 |
hardwareId = "/dev/dvd" |
| 969 |
driveSpeed = None |
| 970 |
imagePath = "/path/to/image" |
| 971 |
entries = None |
| 972 |
mediaLabel = None |
| 973 |
dryRun = True |
| 974 |
expected = [ |
| 975 |
"-use-the-force-luke=tty", |
| 976 |
"-dry-run", |
| 977 |
"-Z", |
| 978 |
"/dev/dvd=/path/to/image", |
| 979 |
] |
| 980 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 981 |
self.assertEqual(actual, expected) |
| 982 |
|
| 983 |
def testBuildWriteArgs_007(self): |
| 984 |
""" |
| 985 |
Test with newDisc=False, hardwareId="/dev/dvd", driveSpeed=1, |
| 986 |
imagePath="/path/to/image", entries=None, mediaLabel=None, dryRun=False. |
| 987 |
""" |
| 988 |
newDisc = False |
| 989 |
hardwareId = "/dev/dvd" |
| 990 |
driveSpeed = 1 |
| 991 |
imagePath = "/path/to/image" |
| 992 |
entries = None |
| 993 |
mediaLabel = None |
| 994 |
dryRun = False |
| 995 |
expected = [ |
| 996 |
"-use-the-force-luke=tty", |
| 997 |
"-speed=1", |
| 998 |
"-M", |
| 999 |
"/dev/dvd=/path/to/image", |
| 1000 |
] |
| 1001 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1002 |
self.assertEqual(actual, expected) |
| 1003 |
|
| 1004 |
def testBuildWriteArgs_008(self): |
| 1005 |
""" |
| 1006 |
Test with newDisc=False, hardwareId="/dev/dvd", driveSpeed=2, |
| 1007 |
imagePath="/path/to/image", entries=None, mediaLabel=None, dryRun=True. |
| 1008 |
""" |
| 1009 |
newDisc = False |
| 1010 |
hardwareId = "/dev/dvd" |
| 1011 |
driveSpeed = 2 |
| 1012 |
imagePath = "/path/to/image" |
| 1013 |
entries = None |
| 1014 |
mediaLabel = None |
| 1015 |
dryRun = True |
| 1016 |
expected = [ |
| 1017 |
"-use-the-force-luke=tty", |
| 1018 |
"-dry-run", |
| 1019 |
"-speed=2", |
| 1020 |
"-M", |
| 1021 |
"/dev/dvd=/path/to/image", |
| 1022 |
] |
| 1023 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1024 |
self.assertEqual(actual, expected) |
| 1025 |
|
| 1026 |
def testBuildWriteArgs_009(self): |
| 1027 |
""" |
| 1028 |
Test with newDisc=True, hardwareId="/dev/dvd", driveSpeed=3, |
| 1029 |
imagePath="/path/to/image", entries=None, mediaLabel=None, dryRun=False. |
| 1030 |
""" |
| 1031 |
newDisc = True |
| 1032 |
hardwareId = "/dev/dvd" |
| 1033 |
driveSpeed = 3 |
| 1034 |
imagePath = "/path/to/image" |
| 1035 |
entries = None |
| 1036 |
mediaLabel = None |
| 1037 |
dryRun = False |
| 1038 |
expected = [ |
| 1039 |
"-use-the-force-luke=tty", |
| 1040 |
"-speed=3", |
| 1041 |
"-Z", |
| 1042 |
"/dev/dvd=/path/to/image", |
| 1043 |
] |
| 1044 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1045 |
self.assertEqual(actual, expected) |
| 1046 |
|
| 1047 |
def testBuildWriteArgs_010(self): |
| 1048 |
""" |
| 1049 |
Test with newDisc=True, hardwareId="/dev/dvd", driveSpeed=4, |
| 1050 |
imagePath="/path/to/image", entries=None, mediaLabel=None, dryRun=True. |
| 1051 |
""" |
| 1052 |
newDisc = True |
| 1053 |
hardwareId = "/dev/dvd" |
| 1054 |
driveSpeed = 4 |
| 1055 |
imagePath = "/path/to/image" |
| 1056 |
entries = None |
| 1057 |
mediaLabel = None |
| 1058 |
dryRun = True |
| 1059 |
expected = [ |
| 1060 |
"-use-the-force-luke=tty", |
| 1061 |
"-dry-run", |
| 1062 |
"-speed=4", |
| 1063 |
"-Z", |
| 1064 |
"/dev/dvd=/path/to/image", |
| 1065 |
] |
| 1066 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1067 |
self.assertEqual(actual, expected) |
| 1068 |
|
| 1069 |
def testBuildWriteArgs_011(self): |
| 1070 |
""" |
| 1071 |
Test with newDisc=False, hardwareId="/dev/dvd", driveSpeed=None, |
| 1072 |
imagePath=None, entries=<one>, mediaLabel=None, dryRun=False. |
| 1073 |
""" |
| 1074 |
newDisc = False |
| 1075 |
hardwareId = "/dev/dvd" |
| 1076 |
driveSpeed = None |
| 1077 |
imagePath = None |
| 1078 |
entries = { |
| 1079 |
"path1": None, |
| 1080 |
} |
| 1081 |
mediaLabel = None |
| 1082 |
dryRun = False |
| 1083 |
expected = [ |
| 1084 |
"-use-the-force-luke=tty", |
| 1085 |
"-M", |
| 1086 |
"/dev/dvd", |
| 1087 |
"-r", |
| 1088 |
"-graft-points", |
| 1089 |
"path1", |
| 1090 |
] |
| 1091 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1092 |
self.assertEqual(actual, expected) |
| 1093 |
|
| 1094 |
def testBuildWriteArgs_012(self): |
| 1095 |
""" |
| 1096 |
Test with newDisc=False, hardwareId="/dev/dvd", driveSpeed=None, |
| 1097 |
imagePath=None, entries=<one>, mediaLabel=None, dryRun=True. |
| 1098 |
""" |
| 1099 |
newDisc = False |
| 1100 |
hardwareId = "/dev/dvd" |
| 1101 |
driveSpeed = None |
| 1102 |
imagePath = None |
| 1103 |
entries = { |
| 1104 |
"path1": None, |
| 1105 |
} |
| 1106 |
mediaLabel = None |
| 1107 |
dryRun = True |
| 1108 |
expected = [ |
| 1109 |
"-use-the-force-luke=tty", |
| 1110 |
"-dry-run", |
| 1111 |
"-M", |
| 1112 |
"/dev/dvd", |
| 1113 |
"-r", |
| 1114 |
"-graft-points", |
| 1115 |
"path1", |
| 1116 |
] |
| 1117 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1118 |
self.assertEqual(actual, expected) |
| 1119 |
|
| 1120 |
def testBuildWriteArgs_013(self): |
| 1121 |
""" |
| 1122 |
Test with newDisc=True, hardwareId="/dev/dvd", driveSpeed=None, |
| 1123 |
imagePath=None, entries=<several>, mediaLabel=None, dryRun=False. |
| 1124 |
""" |
| 1125 |
newDisc = True |
| 1126 |
hardwareId = "/dev/dvd" |
| 1127 |
driveSpeed = None |
| 1128 |
imagePath = None |
| 1129 |
entries = { |
| 1130 |
"path1": None, |
| 1131 |
"path2": "graft2", |
| 1132 |
"path3": "/path/to/graft3", |
| 1133 |
} |
| 1134 |
mediaLabel = None |
| 1135 |
dryRun = False |
| 1136 |
expected = [ |
| 1137 |
"-use-the-force-luke=tty", |
| 1138 |
"-Z", |
| 1139 |
"/dev/dvd", |
| 1140 |
"-r", |
| 1141 |
"-graft-points", |
| 1142 |
"path1", |
| 1143 |
"graft2/=path2", |
| 1144 |
"path/to/graft3/=path3", |
| 1145 |
] |
| 1146 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1147 |
self.assertEqual(actual, expected) |
| 1148 |
|
| 1149 |
def testBuildWriteArgs_014(self): |
| 1150 |
""" |
| 1151 |
Test with newDisc=True, hardwareId="/dev/dvd", driveSpeed=None, |
| 1152 |
imagePath=None, entries=<several>, mediaLabel=None, dryRun=True. |
| 1153 |
""" |
| 1154 |
newDisc = True |
| 1155 |
hardwareId = "/dev/dvd" |
| 1156 |
driveSpeed = None |
| 1157 |
imagePath = None |
| 1158 |
entries = { |
| 1159 |
"path1": None, |
| 1160 |
"path2": "graft2", |
| 1161 |
"path3": "/path/to/graft3", |
| 1162 |
} |
| 1163 |
mediaLabel = None |
| 1164 |
dryRun = True |
| 1165 |
expected = [ |
| 1166 |
"-use-the-force-luke=tty", |
| 1167 |
"-dry-run", |
| 1168 |
"-Z", |
| 1169 |
"/dev/dvd", |
| 1170 |
"-r", |
| 1171 |
"-graft-points", |
| 1172 |
"path1", |
| 1173 |
"graft2/=path2", |
| 1174 |
"path/to/graft3/=path3", |
| 1175 |
] |
| 1176 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1177 |
self.assertEqual(actual, expected) |
| 1178 |
|
| 1179 |
def testBuildWriteArgs_015(self): |
| 1180 |
""" |
| 1181 |
Test with newDisc=False, hardwareId="/dev/dvd", driveSpeed=1, |
| 1182 |
imagePath=None, entries=<several>, mediaLabel=None, dryRun=False. |
| 1183 |
""" |
| 1184 |
newDisc = False |
| 1185 |
hardwareId = "/dev/dvd" |
| 1186 |
driveSpeed = 1 |
| 1187 |
imagePath = None |
| 1188 |
entries = { |
| 1189 |
"path1": None, |
| 1190 |
"path2": "graft2", |
| 1191 |
} |
| 1192 |
mediaLabel = None |
| 1193 |
dryRun = False |
| 1194 |
expected = [ |
| 1195 |
"-use-the-force-luke=tty", |
| 1196 |
"-speed=1", |
| 1197 |
"-M", |
| 1198 |
"/dev/dvd", |
| 1199 |
"-r", |
| 1200 |
"-graft-points", |
| 1201 |
"path1", |
| 1202 |
"graft2/=path2", |
| 1203 |
] |
| 1204 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1205 |
self.assertEqual(actual, expected) |
| 1206 |
|
| 1207 |
def testBuildWriteArgs_016(self): |
| 1208 |
""" |
| 1209 |
Test with newDisc=False, hardwareId="/dev/dvd", driveSpeed=2, |
| 1210 |
imagePath=None, entries=<several>, mediaLabel=None, dryRun=True. |
| 1211 |
""" |
| 1212 |
newDisc = False |
| 1213 |
hardwareId = "/dev/dvd" |
| 1214 |
driveSpeed = 2 |
| 1215 |
imagePath = None |
| 1216 |
entries = { |
| 1217 |
"path1": None, |
| 1218 |
"path2": "graft2", |
| 1219 |
} |
| 1220 |
mediaLabel = None |
| 1221 |
dryRun = True |
| 1222 |
expected = [ |
| 1223 |
"-use-the-force-luke=tty", |
| 1224 |
"-dry-run", |
| 1225 |
"-speed=2", |
| 1226 |
"-M", |
| 1227 |
"/dev/dvd", |
| 1228 |
"-r", |
| 1229 |
"-graft-points", |
| 1230 |
"path1", |
| 1231 |
"graft2/=path2", |
| 1232 |
] |
| 1233 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1234 |
self.assertEqual(actual, expected) |
| 1235 |
|
| 1236 |
def testBuildWriteArgs_017(self): |
| 1237 |
""" |
| 1238 |
Test with newDisc=True, hardwareId="/dev/dvd", driveSpeed=3, |
| 1239 |
imagePath=None, entries=<several>, mediaLabel=None, dryRun=False. |
| 1240 |
""" |
| 1241 |
newDisc = True |
| 1242 |
hardwareId = "/dev/dvd" |
| 1243 |
driveSpeed = 3 |
| 1244 |
imagePath = None |
| 1245 |
entries = { |
| 1246 |
"path1": None, |
| 1247 |
"/path/to/path2": None, |
| 1248 |
"/path/to/path3/": "/path/to/graft3/", |
| 1249 |
} |
| 1250 |
mediaLabel = None |
| 1251 |
dryRun = False |
| 1252 |
expected = [ |
| 1253 |
"-use-the-force-luke=tty", |
| 1254 |
"-speed=3", |
| 1255 |
"-Z", |
| 1256 |
"/dev/dvd", |
| 1257 |
"-r", |
| 1258 |
"-graft-points", |
| 1259 |
"/path/to/path2", |
| 1260 |
"path/to/graft3/=/path/to/path3/", |
| 1261 |
"path1", |
| 1262 |
] # sorted order |
| 1263 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1264 |
self.assertEqual(actual, expected) |
| 1265 |
|
| 1266 |
def testBuildWriteArgs_018(self): |
| 1267 |
""" |
| 1268 |
Test with newDisc=True, hardwareId="/dev/dvd", driveSpeed=4, |
| 1269 |
imagePath=None, entries=<several>, mediaLabel=None, dryRun=True. |
| 1270 |
""" |
| 1271 |
newDisc = True |
| 1272 |
hardwareId = "/dev/dvd" |
| 1273 |
driveSpeed = 4 |
| 1274 |
imagePath = None |
| 1275 |
entries = { |
| 1276 |
"path1": None, |
| 1277 |
"/path/to/path2": None, |
| 1278 |
"/path/to/path3/": "/path/to/graft3/", |
| 1279 |
} |
| 1280 |
mediaLabel = None |
| 1281 |
dryRun = True |
| 1282 |
expected = [ |
| 1283 |
"-use-the-force-luke=tty", |
| 1284 |
"-dry-run", |
| 1285 |
"-speed=4", |
| 1286 |
"-Z", |
| 1287 |
"/dev/dvd", |
| 1288 |
"-r", |
| 1289 |
"-graft-points", |
| 1290 |
"/path/to/path2", |
| 1291 |
"path/to/graft3/=/path/to/path3/", |
| 1292 |
"path1", |
| 1293 |
] # sorted order |
| 1294 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1295 |
self.assertEqual(actual, expected) |
| 1296 |
|
| 1297 |
def testBuildWriteArgs_019(self): |
| 1298 |
""" |
| 1299 |
Test with newDisc=True, hardwareId="/dev/dvd", driveSpeed=3, |
| 1300 |
imagePath="/path/to/image", entries=None, mediaLabel="BACKUP", dryRun=False. |
| 1301 |
""" |
| 1302 |
newDisc = True |
| 1303 |
hardwareId = "/dev/dvd" |
| 1304 |
driveSpeed = 3 |
| 1305 |
imagePath = "/path/to/image" |
| 1306 |
entries = None |
| 1307 |
mediaLabel = "BACKUP" |
| 1308 |
dryRun = False |
| 1309 |
expected = [ |
| 1310 |
"-use-the-force-luke=tty", |
| 1311 |
"-speed=3", |
| 1312 |
"-Z", |
| 1313 |
"/dev/dvd=/path/to/image", |
| 1314 |
] |
| 1315 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1316 |
self.assertEqual(actual, expected) |
| 1317 |
|
| 1318 |
def testBuildWriteArgs_020(self): |
| 1319 |
""" |
| 1320 |
Test with newDisc=True, hardwareId="/dev/dvd", driveSpeed=4, |
| 1321 |
imagePath=None, entries=<several>, mediaLabel="BACKUP", dryRun=True. |
| 1322 |
""" |
| 1323 |
newDisc = True |
| 1324 |
hardwareId = "/dev/dvd" |
| 1325 |
driveSpeed = 4 |
| 1326 |
imagePath = None |
| 1327 |
entries = { |
| 1328 |
"path1": None, |
| 1329 |
"/path/to/path2": None, |
| 1330 |
"/path/to/path3/": "/path/to/graft3/", |
| 1331 |
} |
| 1332 |
mediaLabel = "BACKUP" |
| 1333 |
dryRun = True |
| 1334 |
expected = [ |
| 1335 |
"-use-the-force-luke=tty", |
| 1336 |
"-dry-run", |
| 1337 |
"-speed=4", |
| 1338 |
"-Z", |
| 1339 |
"/dev/dvd", |
| 1340 |
"-V", |
| 1341 |
"BACKUP", |
| 1342 |
"-r", |
| 1343 |
"-graft-points", |
| 1344 |
"/path/to/path2", |
| 1345 |
"path/to/graft3/=/path/to/path3/", |
| 1346 |
"path1", |
| 1347 |
] # sorted order |
| 1348 |
actual = DvdWriter._buildWriteArgs(newDisc, hardwareId, driveSpeed, imagePath, entries, mediaLabel, dryRun) |
| 1349 |
self.assertEqual(actual, expected) |