| 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) 2004-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 CD writer functionality. |
| 30 |
# |
| 31 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
| 32 |
|
| 33 |
######################################################################## |
| 34 |
# Module documentation |
| 35 |
######################################################################## |
| 36 |
|
| 37 |
""" |
| 38 |
Unit tests for CedarBackup3/writers/cdwriter.py. |
| 39 |
|
| 40 |
This code was consolidated from writertests.py and imagetests.py at the same |
| 41 |
time cdwriter.py was created. |
| 42 |
|
| 43 |
Code Coverage |
| 44 |
============= |
| 45 |
|
| 46 |
This module contains individual tests for the public classes implemented in |
| 47 |
cdwriter.py. |
| 48 |
|
| 49 |
Unfortunately, it's rather difficult to test this code in an automated |
| 50 |
fashion, even if you have access to a physical CD writer drive. It's even |
| 51 |
more difficult to test it if you are running on some build daemon (think of |
| 52 |
a Debian autobuilder) which can't be expected to have any hardware or any |
| 53 |
media that you could write to. Because of this, there aren't any tests |
| 54 |
below that actually cause CD media to be written to. |
| 55 |
|
| 56 |
As a compromise, much of the implementation is in terms of private static |
| 57 |
methods that have well-defined behaviors. Normally, I prefer to only test |
| 58 |
the public interface to class, but in this case, testing the private methods |
| 59 |
will help give us some reasonable confidence in the code, even if we can't |
| 60 |
write a physical disc or can't run all of the tests. This isn't perfect, |
| 61 |
but it's better than nothing. |
| 62 |
|
| 63 |
Naming Conventions |
| 64 |
================== |
| 65 |
|
| 66 |
I prefer to avoid large unit tests which validate more than one piece of |
| 67 |
functionality, and I prefer to avoid using overly descriptive (read: long) |
| 68 |
test names, as well. Instead, I use lots of very small tests that each |
| 69 |
validate one specific thing. These small tests are then named with an index |
| 70 |
number, yielding something like ``testAddDir_001`` or ``testValidate_010``. |
| 71 |
Each method has a docstring describing what it's supposed to accomplish. I |
| 72 |
feel that this makes it easier to judge how important a given failure is, |
| 73 |
and also makes it somewhat easier to diagnose and fix individual problems. |
| 74 |
|
| 75 |
Full vs. Reduced Tests |
| 76 |
====================== |
| 77 |
|
| 78 |
Some Cedar Backup regression tests require a specialized environment in |
| 79 |
order to run successfully. This environment won't necessarily be available |
| 80 |
on every build system out there (for instance, on a Debian autobuilder). |
| 81 |
Because of this, the default behavior is to run a "reduced feature set" test |
| 82 |
suite that has no surprising system, kernel or network requirements. There |
| 83 |
are no special dependencies for these tests. |
| 84 |
|
| 85 |
I used to try and run tests against an actual device, to make sure that this |
| 86 |
worked. However, those tests ended up being kind of bogus, because my main |
| 87 |
development environment doesn't have a writer, and even if it had one, any |
| 88 |
device with the same name on another user's system wouldn't necessarily |
| 89 |
return sensible results. That's just pointless. We'll just have to rely on |
| 90 |
the other tests to make sure that things seem sensible. |
| 91 |
|
| 92 |
@author Kenneth J. Pronovici <[email protected]> |
| 93 |
""" |
| 94 |
|
| 95 |
|
| 96 |
######################################################################## |
| 97 |
# Import modules and do runtime validations |
| 98 |
######################################################################## |
| 99 |
|
| 100 |
import unittest |
| 101 |
|
| 102 |
from CedarBackup3.testutil import configureLogging |
| 103 |
from CedarBackup3.writers.cdwriter import ( |
| 104 |
MEDIA_CDR_74, |
| 105 |
MEDIA_CDR_80, |
| 106 |
MEDIA_CDRW_74, |
| 107 |
MEDIA_CDRW_80, |
| 108 |
CdWriter, |
| 109 |
MediaCapacity, |
| 110 |
MediaDefinition, |
| 111 |
) |
| 112 |
|
| 113 |
####################################################################### |
| 114 |
# Module-wide configuration and constants |
| 115 |
####################################################################### |
| 116 |
|
| 117 |
MB650 = 650.0 * 1024.0 * 1024.0 # 650 MB |
| 118 |
MB700 = 700.0 * 1024.0 * 1024.0 # 700 MB |
| 119 |
ILEAD = 11400.0 * 2048.0 # Initial lead-in |
| 120 |
SLEAD = 6900.0 * 2048.0 # Session lead-in |
| 121 |
|
| 122 |
DATA_DIRS = [ |
| 123 |
"./data", |
| 124 |
"./tests/data", |
| 125 |
] |
| 126 |
RESOURCES = [ |
| 127 |
"tree9.tar.gz", |
| 128 |
] |
| 129 |
|
| 130 |
SUDO_CMD = [ |
| 131 |
"sudo", |
| 132 |
] |
| 133 |
HDIUTIL_CMD = [ |
| 134 |
"hdiutil", |
| 135 |
] |
| 136 |
|
| 137 |
INVALID_FILE = "bogus" # This file name should never exist |
| 138 |
|
| 139 |
|
| 140 |
####################################################################### |
| 141 |
# Test Case Classes |
| 142 |
####################################################################### |
| 143 |
|
| 144 |
############################ |
| 145 |
# TestMediaDefinition class |
| 146 |
############################ |
| 147 |
|
| 148 |
|
| 149 |
class TestMediaDefinition(unittest.TestCase): |
| 150 |
"""Tests for the MediaDefinition class.""" |
| 151 |
|
| 152 |
@classmethod |
| 153 |
def setUpClass(cls): |
| 154 |
configureLogging() |
| 155 |
|
| 156 |
def testConstructor_001(self): |
| 157 |
""" |
| 158 |
Test the constructor with an invalid media type. |
| 159 |
""" |
| 160 |
self.assertRaises(ValueError, MediaDefinition, 100) |
| 161 |
|
| 162 |
def testConstructor_002(self): |
| 163 |
""" |
| 164 |
Test the constructor with the ``MEDIA_CDR_74`` media type. |
| 165 |
""" |
| 166 |
media = MediaDefinition(MEDIA_CDR_74) |
| 167 |
self.assertEqual(MEDIA_CDR_74, media.mediaType) |
| 168 |
self.assertEqual(False, media.rewritable) |
| 169 |
self.assertNotEqual(0, media.initialLeadIn) # just care that it's set, not what its value is |
| 170 |
self.assertNotEqual(0, media.leadIn) # just care that it's set, not what its value is |
| 171 |
self.assertEqual(332800, media.capacity) |
| 172 |
|
| 173 |
def testConstructor_003(self): |
| 174 |
""" |
| 175 |
Test the constructor with the ``MEDIA_CDRW_74`` media type. |
| 176 |
""" |
| 177 |
media = MediaDefinition(MEDIA_CDRW_74) |
| 178 |
self.assertEqual(MEDIA_CDRW_74, media.mediaType) |
| 179 |
self.assertEqual(True, media.rewritable) |
| 180 |
self.assertNotEqual(0, media.initialLeadIn) # just care that it's set, not what its value is |
| 181 |
self.assertNotEqual(0, media.leadIn) # just care that it's set, not what its value is |
| 182 |
self.assertEqual(332800, media.capacity) |
| 183 |
|
| 184 |
def testConstructor_004(self): |
| 185 |
""" |
| 186 |
Test the constructor with the ``MEDIA_CDR_80`` media type. |
| 187 |
""" |
| 188 |
media = MediaDefinition(MEDIA_CDR_80) |
| 189 |
self.assertEqual(MEDIA_CDR_80, media.mediaType) |
| 190 |
self.assertEqual(False, media.rewritable) |
| 191 |
self.assertNotEqual(0, media.initialLeadIn) # just care that it's set, not what its value is |
| 192 |
self.assertNotEqual(0, media.leadIn) # just care that it's set, not what its value is |
| 193 |
self.assertEqual(358400, media.capacity) |
| 194 |
|
| 195 |
def testConstructor_005(self): |
| 196 |
""" |
| 197 |
Test the constructor with the ``MEDIA_CDRW_80`` media type. |
| 198 |
""" |
| 199 |
media = MediaDefinition(MEDIA_CDRW_80) |
| 200 |
self.assertEqual(MEDIA_CDRW_80, media.mediaType) |
| 201 |
self.assertEqual(True, media.rewritable) |
| 202 |
self.assertNotEqual(0, media.initialLeadIn) # just care that it's set, not what its value is |
| 203 |
self.assertNotEqual(0, media.leadIn) # just care that it's set, not what its value is |
| 204 |
self.assertEqual(358400, media.capacity) |
| 205 |
|
| 206 |
|
| 207 |
############################ |
| 208 |
# TestMediaCapacity class |
| 209 |
############################ |
| 210 |
|
| 211 |
|
| 212 |
class TestMediaCapacity(unittest.TestCase): |
| 213 |
"""Tests for the MediaCapacity class.""" |
| 214 |
|
| 215 |
@classmethod |
| 216 |
def setUpClass(cls): |
| 217 |
configureLogging() |
| 218 |
|
| 219 |
def testConstructor_001(self): |
| 220 |
""" |
| 221 |
Test the constructor. |
| 222 |
""" |
| 223 |
capacity = MediaCapacity(100, 200, (300, 400)) |
| 224 |
self.assertEqual(100, capacity.bytesUsed) |
| 225 |
self.assertEqual(200, capacity.bytesAvailable) |
| 226 |
self.assertEqual((300, 400), capacity.boundaries) |
| 227 |
|
| 228 |
|
| 229 |
##################### |
| 230 |
# TestCdWriter class |
| 231 |
##################### |
| 232 |
|
| 233 |
|
| 234 |
class TestCdWriter(unittest.TestCase): |
| 235 |
"""Tests for the CdWriter class.""" |
| 236 |
|
| 237 |
################ |
| 238 |
# Setup methods |
| 239 |
################ |
| 240 |
|
| 241 |
@classmethod |
| 242 |
def setUpClass(cls): |
| 243 |
configureLogging() |
| 244 |
|
| 245 |
def setUp(self): |
| 246 |
pass |
| 247 |
|
| 248 |
def tearDown(self): |
| 249 |
pass |
| 250 |
|
| 251 |
################### |
| 252 |
# Test constructor |
| 253 |
################### |
| 254 |
|
| 255 |
def testConstructor_001(self): |
| 256 |
""" |
| 257 |
Test the constructor with device ``/dev/null``, which is writable and exists. |
| 258 |
Use a valid non-ATA SCSI id and defaults for the remaining arguments. Make sure |
| 259 |
that ``unittest=True`` |
| 260 |
""" |
| 261 |
writer = CdWriter(device="/dev/null", scsiId="0,0,0", unittest=True) |
| 262 |
self.assertEqual("/dev/null", writer.device) |
| 263 |
self.assertEqual("0,0,0", writer.scsiId) |
| 264 |
self.assertEqual("0,0,0", writer.hardwareId) |
| 265 |
self.assertEqual(None, writer.driveSpeed) |
| 266 |
self.assertEqual(MEDIA_CDRW_74, writer.media.mediaType) |
| 267 |
self.assertEqual(True, writer.isRewritable()) |
| 268 |
self.assertEqual(False, writer._noEject) |
| 269 |
|
| 270 |
def testConstructor_002(self): |
| 271 |
""" |
| 272 |
Test the constructor with device ``/dev/null``, which is writable and exists. |
| 273 |
Use a valid ATA SCSI id and defaults for the remaining arguments. Make sure |
| 274 |
that ``unittest=True``. |
| 275 |
""" |
| 276 |
writer = CdWriter(device="/dev/null", scsiId="ATA:0,0,0", unittest=True) |
| 277 |
self.assertEqual("/dev/null", writer.device) |
| 278 |
self.assertEqual("ATA:0,0,0", writer.scsiId) |
| 279 |
self.assertEqual("ATA:0,0,0", writer.hardwareId) |
| 280 |
self.assertEqual(None, writer.driveSpeed) |
| 281 |
self.assertEqual(MEDIA_CDRW_74, writer.media.mediaType) |
| 282 |
self.assertEqual(True, writer.isRewritable()) |
| 283 |
self.assertEqual(False, writer._noEject) |
| 284 |
|
| 285 |
def testConstructor_003(self): |
| 286 |
""" |
| 287 |
Test the constructor with device ``/dev/null``, which is writable and exists. |
| 288 |
Use a valid ATAPI SCSI id and defaults for the remaining arguments. Make sure |
| 289 |
that ``unittest=True``. |
| 290 |
""" |
| 291 |
writer = CdWriter(device="/dev/null", scsiId="ATAPI:0,0,0", unittest=True) |
| 292 |
self.assertEqual("/dev/null", writer.device) |
| 293 |
self.assertEqual("ATAPI:0,0,0", writer.scsiId) |
| 294 |
self.assertEqual("ATAPI:0,0,0", writer.hardwareId) |
| 295 |
self.assertEqual(None, writer.driveSpeed) |
| 296 |
self.assertEqual(MEDIA_CDRW_74, writer.media.mediaType) |
| 297 |
self.assertEqual(True, writer.isRewritable()) |
| 298 |
self.assertEqual(False, writer._noEject) |
| 299 |
|
| 300 |
def testConstructor_004(self): |
| 301 |
""" |
| 302 |
Test the constructor with device ``/dev/null`` (which is writable and exists). |
| 303 |
Use an invalid SCSI id and defaults for the remaining arguments. Make sure that |
| 304 |
``unittest=False``. |
| 305 |
""" |
| 306 |
self.assertRaises(ValueError, CdWriter, device="/dev/null", scsiId="blech", unittest=False) |
| 307 |
|
| 308 |
def testConstructor_005(self): |
| 309 |
""" |
| 310 |
Test the constructor with device ``/dev/null`` (which is writable and exists). |
| 311 |
Use an invalid SCSI id and defaults for the remaining arguments. Make sure that |
| 312 |
``unittest=True``. |
| 313 |
""" |
| 314 |
self.assertRaises(ValueError, CdWriter, device="/dev/null", scsiId="blech", unittest=True) |
| 315 |
|
| 316 |
def testConstructor_006(self): |
| 317 |
""" |
| 318 |
Test the constructor with a non-absolute device path. Use a valid SCSI |
| 319 |
id and defaults for the remaining arguments. Make sure that ``unittest=False``. |
| 320 |
""" |
| 321 |
self.assertRaises(ValueError, CdWriter, device="dev/null", scsiId="0,0,0", unittest=False) |
| 322 |
|
| 323 |
def testConstructor_007(self): |
| 324 |
""" |
| 325 |
Test the constructor with a non-absolute device path. Use a valid SCSI |
| 326 |
id and defaults for the remaining arguments. Make sure that ``unittest=True``. |
| 327 |
""" |
| 328 |
self.assertRaises(ValueError, CdWriter, device="dev/null", scsiId="0,0,0", unittest=True) |
| 329 |
|
| 330 |
def testConstructor_008(self): |
| 331 |
""" |
| 332 |
Test the constructor with an absolute device path that does not exist. |
| 333 |
Use a valid SCSI id and defaults for the remaining arguments. Make sure |
| 334 |
that ``unittest=False``. |
| 335 |
""" |
| 336 |
self.assertRaises(ValueError, CdWriter, device="/bogus", scsiId="0,0,0", unittest=False) |
| 337 |
|
| 338 |
def testConstructor_009(self): |
| 339 |
""" |
| 340 |
Test the constructor with an absolute device path that does not exist. |
| 341 |
Use a valid SCSI id and defaults for the remaining arguments. Make sure |
| 342 |
that ``unittest=True``. |
| 343 |
""" |
| 344 |
writer = CdWriter(device="/bogus", scsiId="0,0,0", unittest=True) |
| 345 |
self.assertEqual("/bogus", writer.device) |
| 346 |
self.assertEqual("0,0,0", writer.scsiId) |
| 347 |
self.assertEqual("0,0,0", writer.hardwareId) |
| 348 |
self.assertEqual(None, writer.driveSpeed) |
| 349 |
self.assertEqual(MEDIA_CDRW_74, writer.media.mediaType) |
| 350 |
self.assertEqual(True, writer.isRewritable()) |
| 351 |
self.assertEqual(False, writer._noEject) |
| 352 |
|
| 353 |
def testConstructor_010(self): |
| 354 |
""" |
| 355 |
Test the constructor with device ``/dev/null``, which is writable and |
| 356 |
exists. Use a valid SCSI id and a value of 0 for the drive speed. Make |
| 357 |
sure that ``unittest=False``. |
| 358 |
""" |
| 359 |
self.assertRaises(ValueError, CdWriter, device="/dev/null", scsiId="0,0,0", driveSpeed=0, unittest=False) |
| 360 |
|
| 361 |
def testConstructor_011(self): |
| 362 |
""" |
| 363 |
Test the constructor with device ``/dev/null``, which is writable and |
| 364 |
exists. Use a valid SCSI id and a value of 0 for the drive speed. Make |
| 365 |
sure that ``unittest=True``. |
| 366 |
""" |
| 367 |
self.assertRaises(ValueError, CdWriter, device="/dev/null", scsiId="0,0,0", driveSpeed=0, unittest=True) |
| 368 |
|
| 369 |
def testConstructor_012(self): |
| 370 |
""" |
| 371 |
Test the constructor with device ``/dev/null``, which is writable and |
| 372 |
exists. Use a valid SCSI id and a value of 1 for the drive speed. Make |
| 373 |
sure that ``unittest=True``. |
| 374 |
""" |
| 375 |
writer = CdWriter(device="/dev/null", scsiId="0,0,0", driveSpeed=1, unittest=True) |
| 376 |
self.assertEqual("/dev/null", writer.device) |
| 377 |
self.assertEqual("0,0,0", writer.scsiId) |
| 378 |
self.assertEqual("0,0,0", writer.hardwareId) |
| 379 |
self.assertEqual(1, writer.driveSpeed) |
| 380 |
self.assertEqual(MEDIA_CDRW_74, writer.media.mediaType) |
| 381 |
self.assertEqual(True, writer.isRewritable()) |
| 382 |
self.assertEqual(False, writer._noEject) |
| 383 |
|
| 384 |
def testConstructor_013(self): |
| 385 |
""" |
| 386 |
Test the constructor with device ``/dev/null``, which is writable and |
| 387 |
exists. Use a valid SCSI id and a value of 5 for the drive speed. Make |
| 388 |
sure that ``unittest=True``. |
| 389 |
""" |
| 390 |
writer = CdWriter(device="/dev/null", scsiId="0,0,0", driveSpeed=5, unittest=True) |
| 391 |
self.assertEqual("/dev/null", writer.device) |
| 392 |
self.assertEqual("0,0,0", writer.scsiId) |
| 393 |
self.assertEqual("0,0,0", writer.hardwareId) |
| 394 |
self.assertEqual(5, writer.driveSpeed) |
| 395 |
self.assertEqual(MEDIA_CDRW_74, writer.media.mediaType) |
| 396 |
self.assertEqual(True, writer.isRewritable()) |
| 397 |
self.assertEqual(False, writer._noEject) |
| 398 |
|
| 399 |
def testConstructor_014(self): |
| 400 |
""" |
| 401 |
Test the constructor with device ``/dev/null``, which is writable and |
| 402 |
exists. Use a valid SCSI id and an invalid media type. Make sure that |
| 403 |
``unittest=False``. |
| 404 |
""" |
| 405 |
self.assertRaises(ValueError, CdWriter, device="/dev/null", scsiId="0,0,0", mediaType=42, unittest=False) |
| 406 |
|
| 407 |
def testConstructor_015(self): |
| 408 |
""" |
| 409 |
Test the constructor with device ``/dev/null``, which is writable and |
| 410 |
exists. Use a valid SCSI id and an invalid media type. Make sure that |
| 411 |
``unittest=True``. |
| 412 |
""" |
| 413 |
self.assertRaises(ValueError, CdWriter, device="/dev/null", scsiId="0,0,0", mediaType=42, unittest=True) |
| 414 |
|
| 415 |
def testConstructor_016(self): |
| 416 |
""" |
| 417 |
Test the constructor with device ``/dev/null``, which is writable and |
| 418 |
exists. Use a valid SCSI id and a media type of MEDIA_CDR_74. Make sure |
| 419 |
that ``unittest=True``. |
| 420 |
""" |
| 421 |
writer = CdWriter(device="/dev/null", scsiId="0,0,0", mediaType=MEDIA_CDR_74, unittest=True) |
| 422 |
self.assertEqual("/dev/null", writer.device) |
| 423 |
self.assertEqual("0,0,0", writer.scsiId) |
| 424 |
self.assertEqual("0,0,0", writer.hardwareId) |
| 425 |
self.assertEqual(None, writer.driveSpeed) |
| 426 |
self.assertEqual(MEDIA_CDR_74, writer.media.mediaType) |
| 427 |
self.assertEqual(False, writer.isRewritable()) |
| 428 |
self.assertEqual(False, writer._noEject) |
| 429 |
|
| 430 |
def testConstructor_017(self): |
| 431 |
""" |
| 432 |
Test the constructor with device ``/dev/null``, which is writable and |
| 433 |
exists. Use a valid SCSI id and a media type of MEDIA_CDRW_74. Make sure |
| 434 |
that ``unittest=True``. |
| 435 |
""" |
| 436 |
writer = CdWriter(device="/dev/null", scsiId="0,0,0", mediaType=MEDIA_CDRW_74, unittest=True) |
| 437 |
self.assertEqual("/dev/null", writer.device) |
| 438 |
self.assertEqual("0,0,0", writer.scsiId) |
| 439 |
self.assertEqual("0,0,0", writer.hardwareId) |
| 440 |
self.assertEqual(None, writer.driveSpeed) |
| 441 |
self.assertEqual(MEDIA_CDRW_74, writer.media.mediaType) |
| 442 |
self.assertEqual(True, writer.isRewritable()) |
| 443 |
self.assertEqual(False, writer._noEject) |
| 444 |
|
| 445 |
def testConstructor_018(self): |
| 446 |
""" |
| 447 |
Test the constructor with device ``/dev/null``, which is writable and |
| 448 |
exists. Use a valid SCSI id and a media type of MEDIA_CDR_80. Make sure |
| 449 |
that ``unittest=True``. |
| 450 |
""" |
| 451 |
writer = CdWriter(device="/dev/null", scsiId="0,0,0", mediaType=MEDIA_CDR_80, unittest=True) |
| 452 |
self.assertEqual("/dev/null", writer.device) |
| 453 |
self.assertEqual("0,0,0", writer.scsiId) |
| 454 |
self.assertEqual("0,0,0", writer.hardwareId) |
| 455 |
self.assertEqual(None, writer.driveSpeed) |
| 456 |
self.assertEqual(MEDIA_CDR_80, writer.media.mediaType) |
| 457 |
self.assertEqual(False, writer.isRewritable()) |
| 458 |
self.assertEqual(False, writer._noEject) |
| 459 |
|
| 460 |
def testConstructor_019(self): |
| 461 |
""" |
| 462 |
Test the constructor with device ``/dev/null``, which is writable and |
| 463 |
exists. Use a valid SCSI id and a media type of MEDIA_CDRW_80. Make sure |
| 464 |
that ``unittest=True``. |
| 465 |
""" |
| 466 |
writer = CdWriter(device="/dev/null", scsiId="0,0,0", mediaType=MEDIA_CDRW_80, unittest=True) |
| 467 |
self.assertEqual("/dev/null", writer.device) |
| 468 |
self.assertEqual("0,0,0", writer.scsiId) |
| 469 |
self.assertEqual("0,0,0", writer.hardwareId) |
| 470 |
self.assertEqual(None, writer.driveSpeed) |
| 471 |
self.assertEqual(MEDIA_CDRW_80, writer.media.mediaType) |
| 472 |
self.assertEqual(True, writer.isRewritable()) |
| 473 |
self.assertEqual(False, writer._noEject) |
| 474 |
|
| 475 |
def testConstructor_020(self): |
| 476 |
""" |
| 477 |
Test the constructor with device ``/dev/null``, which is writable and |
| 478 |
exists. Use None for SCSI id and a media type of MEDIA_CDRW_80. Make |
| 479 |
sure that ``unittest=True``. |
| 480 |
""" |
| 481 |
writer = CdWriter(device="/dev/null", scsiId=None, mediaType=MEDIA_CDRW_80, unittest=True) |
| 482 |
self.assertEqual("/dev/null", writer.device) |
| 483 |
self.assertEqual(None, writer.scsiId) |
| 484 |
self.assertEqual("/dev/null", writer.hardwareId) |
| 485 |
self.assertEqual(None, writer.driveSpeed) |
| 486 |
self.assertEqual(MEDIA_CDRW_80, writer.media.mediaType) |
| 487 |
self.assertEqual(True, writer.isRewritable()) |
| 488 |
self.assertEqual(False, writer._noEject) |
| 489 |
|
| 490 |
def testConstructor_021(self): |
| 491 |
""" |
| 492 |
Test the constructor with device ``/dev/null``, which is writable and |
| 493 |
exists. Use None for SCSI id and a media type of MEDIA_CDRW_80. Make |
| 494 |
sure that ``unittest=True``. Use ``noEject=True``. |
| 495 |
""" |
| 496 |
writer = CdWriter(device="/dev/null", scsiId=None, mediaType=MEDIA_CDRW_80, noEject=True, unittest=True) |
| 497 |
self.assertEqual("/dev/null", writer.device) |
| 498 |
self.assertEqual(None, writer.scsiId) |
| 499 |
self.assertEqual("/dev/null", writer.hardwareId) |
| 500 |
self.assertEqual(None, writer.driveSpeed) |
| 501 |
self.assertEqual(MEDIA_CDRW_80, writer.media.mediaType) |
| 502 |
self.assertEqual(True, writer.isRewritable()) |
| 503 |
self.assertEqual(True, writer._noEject) |
| 504 |
|
| 505 |
#################################### |
| 506 |
# Test the capacity-related methods |
| 507 |
#################################### |
| 508 |
|
| 509 |
def testCapacity_001(self): |
| 510 |
""" |
| 511 |
Test _calculateCapacity for boundaries of None and MEDIA_CDR_74. |
| 512 |
""" |
| 513 |
expectedAvailable = MB650 - ILEAD # 650 MB, minus initial lead-in |
| 514 |
media = MediaDefinition(MEDIA_CDR_74) |
| 515 |
boundaries = None |
| 516 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 517 |
self.assertEqual(0, capacity.bytesUsed) |
| 518 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 519 |
self.assertEqual(None, capacity.boundaries) |
| 520 |
|
| 521 |
def testCapacity_002(self): |
| 522 |
""" |
| 523 |
Test _calculateCapacity for boundaries of None and MEDIA_CDRW_74. |
| 524 |
""" |
| 525 |
expectedAvailable = MB650 - ILEAD # 650 MB, minus initial lead-in |
| 526 |
media = MediaDefinition(MEDIA_CDRW_74) |
| 527 |
boundaries = None |
| 528 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 529 |
self.assertEqual(0, capacity.bytesUsed) |
| 530 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 531 |
self.assertEqual(None, capacity.boundaries) |
| 532 |
|
| 533 |
def testCapacity_003(self): |
| 534 |
""" |
| 535 |
Test _calculateCapacity for boundaries of None and MEDIA_CDR_80. |
| 536 |
""" |
| 537 |
expectedAvailable = MB700 - ILEAD # 700 MB, minus initial lead-in |
| 538 |
media = MediaDefinition(MEDIA_CDR_80) |
| 539 |
boundaries = None |
| 540 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 541 |
self.assertEqual(0, capacity.bytesUsed) |
| 542 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 543 |
self.assertEqual(None, capacity.boundaries) |
| 544 |
|
| 545 |
def testCapacity_004(self): |
| 546 |
""" |
| 547 |
Test _calculateCapacity for boundaries of None and MEDIA_CDRW_80. |
| 548 |
""" |
| 549 |
expectedAvailable = MB700 - ILEAD # 700 MB, minus initial lead-in |
| 550 |
media = MediaDefinition(MEDIA_CDRW_80) |
| 551 |
boundaries = None |
| 552 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 553 |
self.assertEqual(0, capacity.bytesUsed) |
| 554 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 555 |
self.assertEqual(None, capacity.boundaries) |
| 556 |
|
| 557 |
def testCapacity_005(self): |
| 558 |
""" |
| 559 |
Test _calculateCapacity for boundaries of (0, 1) and MEDIA_CDR_74. |
| 560 |
""" |
| 561 |
expectedUsed = 1 * 2048.0 # 1 sector |
| 562 |
expectedAvailable = MB650 - SLEAD - expectedUsed # 650 MB, minus session lead-in, minus 1 sector |
| 563 |
media = MediaDefinition(MEDIA_CDR_74) |
| 564 |
boundaries = (0, 1) |
| 565 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 566 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 567 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 568 |
self.assertEqual((0, 1), capacity.boundaries) |
| 569 |
|
| 570 |
def testCapacity_006(self): |
| 571 |
""" |
| 572 |
Test _calculateCapacity for boundaries of (0, 1) and MEDIA_CDRW_74. |
| 573 |
""" |
| 574 |
expectedUsed = 1 * 2048.0 # 1 sector |
| 575 |
expectedAvailable = MB650 - SLEAD - expectedUsed # 650 MB, minus session lead-in, minus 1 sector |
| 576 |
media = MediaDefinition(MEDIA_CDRW_74) |
| 577 |
boundaries = (0, 1) |
| 578 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 579 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 580 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 581 |
self.assertEqual((0, 1), capacity.boundaries) |
| 582 |
|
| 583 |
def testCapacity_007(self): |
| 584 |
""" |
| 585 |
Test _calculateCapacity for boundaries of (0, 1) and MEDIA_CDR_80. |
| 586 |
""" |
| 587 |
expectedUsed = 1 * 2048.0 # 1 sector |
| 588 |
expectedAvailable = MB700 - SLEAD - expectedUsed # 700 MB, minus session lead-in, minus 1 sector |
| 589 |
media = MediaDefinition(MEDIA_CDR_80) |
| 590 |
boundaries = (0, 1) |
| 591 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 592 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 593 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) # 700 MB - lead-in - 1 sector |
| 594 |
self.assertEqual((0, 1), capacity.boundaries) |
| 595 |
|
| 596 |
def testCapacity_008(self): |
| 597 |
""" |
| 598 |
Test _calculateCapacity for boundaries of (0, 1) and MEDIA_CDRW_80. |
| 599 |
""" |
| 600 |
expectedUsed = 1 * 2048.0 # 1 sector |
| 601 |
expectedAvailable = MB700 - SLEAD - expectedUsed # 700 MB, minus session lead-in, minus 1 sector |
| 602 |
media = MediaDefinition(MEDIA_CDRW_80) |
| 603 |
boundaries = (0, 1) |
| 604 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 605 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 606 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 607 |
self.assertEqual((0, 1), capacity.boundaries) |
| 608 |
|
| 609 |
def testCapacity_009(self): |
| 610 |
""" |
| 611 |
Test _calculateCapacity for boundaries of (0, 999) and MEDIA_CDR_74. |
| 612 |
""" |
| 613 |
expectedUsed = 999 * 2048.0 # 999 sectors |
| 614 |
expectedAvailable = MB650 - SLEAD - expectedUsed # 650 MB, minus session lead-in, minus 999 sectors |
| 615 |
media = MediaDefinition(MEDIA_CDR_74) |
| 616 |
boundaries = (0, 999) |
| 617 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 618 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 619 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 620 |
self.assertEqual((0, 999), capacity.boundaries) |
| 621 |
|
| 622 |
def testCapacity_010(self): |
| 623 |
""" |
| 624 |
Test _calculateCapacity for boundaries of (0, 999) and MEDIA_CDRW_74. |
| 625 |
""" |
| 626 |
expectedUsed = 999 * 2048.0 # 999 sectors |
| 627 |
expectedAvailable = MB650 - SLEAD - expectedUsed # 650 MB, minus session lead-in, minus 999 sectors |
| 628 |
media = MediaDefinition(MEDIA_CDRW_74) |
| 629 |
boundaries = (0, 999) |
| 630 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 631 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 632 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 633 |
self.assertEqual((0, 999), capacity.boundaries) |
| 634 |
|
| 635 |
def testCapacity_011(self): |
| 636 |
""" |
| 637 |
Test _calculateCapacity for boundaries of (0, 999) and MEDIA_CDR_80. |
| 638 |
""" |
| 639 |
expectedUsed = 999 * 2048.0 # 999 sectors |
| 640 |
expectedAvailable = MB700 - SLEAD - expectedUsed # 700 MB, minus session lead-in, minus 999 sectors |
| 641 |
media = MediaDefinition(MEDIA_CDR_80) |
| 642 |
boundaries = (0, 999) |
| 643 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 644 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 645 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 646 |
self.assertEqual((0, 999), capacity.boundaries) |
| 647 |
|
| 648 |
def testCapacity_012(self): |
| 649 |
""" |
| 650 |
Test _calculateCapacity for boundaries of (0, 999) and MEDIA_CDRW_80. |
| 651 |
""" |
| 652 |
expectedUsed = 999 * 2048.0 # 999 sectors |
| 653 |
expectedAvailable = MB700 - SLEAD - expectedUsed # 700 MB, minus session lead-in, minus 999 sectors |
| 654 |
media = MediaDefinition(MEDIA_CDRW_80) |
| 655 |
boundaries = (0, 999) |
| 656 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 657 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 658 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 659 |
self.assertEqual((0, 999), capacity.boundaries) |
| 660 |
|
| 661 |
def testCapacity_013(self): |
| 662 |
""" |
| 663 |
Test _calculateCapacity for boundaries of (500, 1000) and MEDIA_CDR_74. |
| 664 |
""" |
| 665 |
expectedUsed = 1000 * 2048.0 # 1000 sectors |
| 666 |
expectedAvailable = MB650 - SLEAD - expectedUsed # 650 MB, minus session lead-in, minus 1000 sectors |
| 667 |
media = MediaDefinition(MEDIA_CDR_74) |
| 668 |
boundaries = (500, 1000) |
| 669 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 670 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 671 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 672 |
self.assertEqual((500, 1000), capacity.boundaries) |
| 673 |
|
| 674 |
def testCapacity_014(self): |
| 675 |
""" |
| 676 |
Test _calculateCapacity for boundaries of (500, 1000) and MEDIA_CDRW_74. |
| 677 |
""" |
| 678 |
expectedUsed = 1000 * 2048.0 # 1000 sectors |
| 679 |
expectedAvailable = MB650 - SLEAD - expectedUsed # 650 MB, minus session lead-in, minus 1000 sectors |
| 680 |
media = MediaDefinition(MEDIA_CDRW_74) |
| 681 |
boundaries = (500, 1000) |
| 682 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 683 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 684 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 685 |
self.assertEqual((500, 1000), capacity.boundaries) |
| 686 |
|
| 687 |
def testCapacity_015(self): |
| 688 |
""" |
| 689 |
Test _calculateCapacity for boundaries of (500, 1000) and MEDIA_CDR_80. |
| 690 |
""" |
| 691 |
expectedUsed = 1000 * 2048.0 # 1000 sectors |
| 692 |
expectedAvailable = MB700 - SLEAD - expectedUsed # 700 MB, minus session lead-in, minus 1000 sectors |
| 693 |
media = MediaDefinition(MEDIA_CDR_80) |
| 694 |
boundaries = (500, 1000) |
| 695 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 696 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 697 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 698 |
self.assertEqual((500, 1000), capacity.boundaries) |
| 699 |
|
| 700 |
def testCapacity_016(self): |
| 701 |
""" |
| 702 |
Test _calculateCapacity for boundaries of (500, 1000) and MEDIA_CDRW_80. |
| 703 |
""" |
| 704 |
expectedUsed = 1000 * 2048.0 # 1000 sectors |
| 705 |
expectedAvailable = MB700 - SLEAD - expectedUsed # 700 MB, minus session lead-in, minus 1000 sectors |
| 706 |
media = MediaDefinition(MEDIA_CDRW_80) |
| 707 |
boundaries = (500, 1000) |
| 708 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 709 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 710 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) # 650 MB minus lead-in |
| 711 |
self.assertEqual((500, 1000), capacity.boundaries) |
| 712 |
|
| 713 |
def testCapacity_017(self): |
| 714 |
""" |
| 715 |
Test _getBoundaries when self.deviceSupportsMulti is False; entireDisc=False, useMulti=True. |
| 716 |
""" |
| 717 |
writer = CdWriter(device="/dev/cdrw", scsiId="0,0,0", unittest=True) |
| 718 |
writer._deviceSupportsMulti = False |
| 719 |
boundaries = writer._getBoundaries(entireDisc=False, useMulti=True) |
| 720 |
self.assertEqual(None, boundaries) |
| 721 |
|
| 722 |
def testCapacity_018(self): |
| 723 |
""" |
| 724 |
Test _getBoundaries when self.deviceSupportsMulti is False; entireDisc=True, useMulti=True. |
| 725 |
""" |
| 726 |
writer = CdWriter(device="/dev/cdrw", scsiId="0,0,0", unittest=True) |
| 727 |
writer._deviceSupportsMulti = False |
| 728 |
boundaries = writer._getBoundaries(entireDisc=True, useMulti=True) |
| 729 |
self.assertEqual(None, boundaries) |
| 730 |
|
| 731 |
def testCapacity_019(self): |
| 732 |
""" |
| 733 |
Test _getBoundaries when self.deviceSupportsMulti is False; entireDisc=True, useMulti=False. |
| 734 |
""" |
| 735 |
writer = CdWriter(device="/dev/cdrw", scsiId="0,0,0", unittest=True) |
| 736 |
writer._deviceSupportsMulti = False |
| 737 |
boundaries = writer._getBoundaries(entireDisc=False, useMulti=False) |
| 738 |
self.assertEqual(None, boundaries) |
| 739 |
|
| 740 |
def testCapacity_020(self): |
| 741 |
""" |
| 742 |
Test _getBoundaries when self.deviceSupportsMulti is False; entireDisc=False, useMulti=False. |
| 743 |
""" |
| 744 |
writer = CdWriter(device="/dev/cdrw", scsiId="0,0,0", unittest=True) |
| 745 |
writer._deviceSupportsMulti = False |
| 746 |
boundaries = writer._getBoundaries(entireDisc=False, useMulti=False) |
| 747 |
self.assertEqual(None, boundaries) |
| 748 |
|
| 749 |
def testCapacity_021(self): |
| 750 |
""" |
| 751 |
Test _getBoundaries when self.deviceSupportsMulti is True; entireDisc=True, useMulti=True. |
| 752 |
""" |
| 753 |
writer = CdWriter(device="/dev/cdrw", scsiId="0,0,0", unittest=True) |
| 754 |
writer._deviceSupportsMulti = True |
| 755 |
boundaries = writer._getBoundaries(entireDisc=True, useMulti=True) |
| 756 |
self.assertEqual(None, boundaries) |
| 757 |
|
| 758 |
def testCapacity_022(self): |
| 759 |
""" |
| 760 |
Test _getBoundaries when self.deviceSupportsMulti is True; entireDisc=True, useMulti=False. |
| 761 |
""" |
| 762 |
writer = CdWriter(device="/dev/cdrw", scsiId="0,0,0", unittest=True) |
| 763 |
writer._deviceSupportsMulti = True |
| 764 |
boundaries = writer._getBoundaries(entireDisc=True, useMulti=False) |
| 765 |
self.assertEqual(None, boundaries) |
| 766 |
|
| 767 |
def testCapacity_023(self): |
| 768 |
""" |
| 769 |
Test _calculateCapacity for boundaries of (321342, 330042) and MEDIA_CDRW_74. |
| 770 |
This was a bug fixed for v2.1.2. |
| 771 |
""" |
| 772 |
expectedUsed = 330042 * 2048.0 # 330042 sectors |
| 773 |
expectedAvailable = 0 # nothing should be available |
| 774 |
media = MediaDefinition(MEDIA_CDRW_74) |
| 775 |
boundaries = (321342, 330042) |
| 776 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 777 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 778 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 779 |
self.assertEqual((321342, 330042), capacity.boundaries) |
| 780 |
|
| 781 |
def testCapacity_024(self): |
| 782 |
""" |
| 783 |
Test _calculateCapacity for boundaries of (0, 330042) and MEDIA_CDRW_74. |
| 784 |
This was a bug fixed for v2.1.3. |
| 785 |
""" |
| 786 |
expectedUsed = 330042 * 2048.0 # 330042 sectors |
| 787 |
expectedAvailable = 0 # nothing should be available |
| 788 |
media = MediaDefinition(MEDIA_CDRW_74) |
| 789 |
boundaries = (0, 330042) |
| 790 |
capacity = CdWriter._calculateCapacity(media, boundaries) |
| 791 |
self.assertEqual(expectedUsed, capacity.bytesUsed) |
| 792 |
self.assertEqual(expectedAvailable, capacity.bytesAvailable) |
| 793 |
self.assertEqual((0, 330042), capacity.boundaries) |
| 794 |
|
| 795 |
######################################### |
| 796 |
# Test methods that build argument lists |
| 797 |
######################################### |
| 798 |
|
| 799 |
def testBuildArgs_001(self): |
| 800 |
""" |
| 801 |
Test _buildOpenTrayArgs(). |
| 802 |
""" |
| 803 |
args = CdWriter._buildOpenTrayArgs(device="/dev/stuff") |
| 804 |
self.assertEqual(["/dev/stuff"], args) |
| 805 |
|
| 806 |
def testBuildArgs_002(self): |
| 807 |
""" |
| 808 |
Test _buildCloseTrayArgs(). |
| 809 |
""" |
| 810 |
args = CdWriter._buildCloseTrayArgs(device="/dev/stuff") |
| 811 |
self.assertEqual(["-t", "/dev/stuff"], args) |
| 812 |
|
| 813 |
def testBuildArgs_003(self): |
| 814 |
""" |
| 815 |
Test _buildPropertiesArgs(). |
| 816 |
""" |
| 817 |
args = CdWriter._buildPropertiesArgs(hardwareId="0,0,0") |
| 818 |
self.assertEqual(["-prcap", "dev=0,0,0"], args) |
| 819 |
|
| 820 |
def testBuildArgs_004(self): |
| 821 |
""" |
| 822 |
Test _buildBoundariesArgs(). |
| 823 |
""" |
| 824 |
args = CdWriter._buildBoundariesArgs(hardwareId="ATA:0,0,0") |
| 825 |
self.assertEqual(["-msinfo", "dev=ATA:0,0,0"], args) |
| 826 |
|
| 827 |
def testBuildArgs_005(self): |
| 828 |
""" |
| 829 |
Test _buildBoundariesArgs(). |
| 830 |
""" |
| 831 |
args = CdWriter._buildBoundariesArgs(hardwareId="ATAPI:0,0,0") |
| 832 |
self.assertEqual(["-msinfo", "dev=ATAPI:0,0,0"], args) |
| 833 |
|
| 834 |
def testBuildArgs_006(self): |
| 835 |
""" |
| 836 |
Test _buildBlankArgs(), default drive speed. |
| 837 |
""" |
| 838 |
args = CdWriter._buildBlankArgs(hardwareId="ATA:0,0,0") |
| 839 |
self.assertEqual(["-v", "blank=fast", "dev=ATA:0,0,0"], args) |
| 840 |
|
| 841 |
def testBuildArgs_007(self): |
| 842 |
""" |
| 843 |
Test _buildBlankArgs(), default drive speed. |
| 844 |
""" |
| 845 |
args = CdWriter._buildBlankArgs(hardwareId="ATAPI:0,0,0") |
| 846 |
self.assertEqual(["-v", "blank=fast", "dev=ATAPI:0,0,0"], args) |
| 847 |
|
| 848 |
def testBuildArgs_008(self): |
| 849 |
""" |
| 850 |
Test _buildBlankArgs(), with None for drive speed. |
| 851 |
""" |
| 852 |
args = CdWriter._buildBlankArgs(hardwareId="0,0,0", driveSpeed=None) |
| 853 |
self.assertEqual(["-v", "blank=fast", "dev=0,0,0"], args) |
| 854 |
|
| 855 |
def testBuildArgs_009(self): |
| 856 |
""" |
| 857 |
Test _buildBlankArgs(), with 1 for drive speed. |
| 858 |
""" |
| 859 |
args = CdWriter._buildBlankArgs(hardwareId="0,0,0", driveSpeed=1) |
| 860 |
self.assertEqual(["-v", "blank=fast", "speed=1", "dev=0,0,0"], args) |
| 861 |
|
| 862 |
def testBuildArgs_010(self): |
| 863 |
""" |
| 864 |
Test _buildBlankArgs(), with 5 for drive speed. |
| 865 |
""" |
| 866 |
args = CdWriter._buildBlankArgs(hardwareId="ATA:1,2,3", driveSpeed=5) |
| 867 |
self.assertEqual(["-v", "blank=fast", "speed=5", "dev=ATA:1,2,3"], args) |
| 868 |
|
| 869 |
def testBuildArgs_011(self): |
| 870 |
""" |
| 871 |
Test _buildBlankArgs(), with 5 for drive speed. |
| 872 |
""" |
| 873 |
args = CdWriter._buildBlankArgs(hardwareId="ATAPI:1,2,3", driveSpeed=5) |
| 874 |
self.assertEqual(["-v", "blank=fast", "speed=5", "dev=ATAPI:1,2,3"], args) |
| 875 |
|
| 876 |
def testBuildArgs_012(self): |
| 877 |
""" |
| 878 |
Test _buildWriteArgs(), default drive speed and writeMulti. |
| 879 |
""" |
| 880 |
args = CdWriter._buildWriteArgs(hardwareId="0,0,0", imagePath="/whatever") |
| 881 |
self.assertEqual(["-v", "dev=0,0,0", "-multi", "-data", "/whatever"], args) |
| 882 |
|
| 883 |
def testBuildArgs_013(self): |
| 884 |
""" |
| 885 |
Test _buildWriteArgs(), None for drive speed, True for writeMulti. |
| 886 |
""" |
| 887 |
args = CdWriter._buildWriteArgs(hardwareId="0,0,0", imagePath="/whatever", driveSpeed=None, writeMulti=True) |
| 888 |
self.assertEqual(["-v", "dev=0,0,0", "-multi", "-data", "/whatever"], args) |
| 889 |
|
| 890 |
def testBuildArgs_014(self): |
| 891 |
""" |
| 892 |
Test _buildWriteArgs(), None for drive speed, False for writeMulti. |
| 893 |
""" |
| 894 |
args = CdWriter._buildWriteArgs(hardwareId="0,0,0", imagePath="/whatever", driveSpeed=None, writeMulti=False) |
| 895 |
self.assertEqual(["-v", "dev=0,0,0", "-data", "/whatever"], args) |
| 896 |
|
| 897 |
def testBuildArgs_015(self): |
| 898 |
""" |
| 899 |
Test _buildWriteArgs(), 1 for drive speed, True for writeMulti. |
| 900 |
""" |
| 901 |
args = CdWriter._buildWriteArgs(hardwareId="0,0,0", imagePath="/whatever", driveSpeed=1, writeMulti=True) |
| 902 |
self.assertEqual(["-v", "speed=1", "dev=0,0,0", "-multi", "-data", "/whatever"], args) |
| 903 |
|
| 904 |
def testBuildArgs_016(self): |
| 905 |
""" |
| 906 |
Test _buildWriteArgs(), 5 for drive speed, True for writeMulti. |
| 907 |
""" |
| 908 |
args = CdWriter._buildWriteArgs(hardwareId="0,1,2", imagePath="/whatever", driveSpeed=5, writeMulti=True) |
| 909 |
self.assertEqual(["-v", "speed=5", "dev=0,1,2", "-multi", "-data", "/whatever"], args) |
| 910 |
|
| 911 |
def testBuildArgs_017(self): |
| 912 |
""" |
| 913 |
Test _buildWriteArgs(), 1 for drive speed, False for writeMulti. |
| 914 |
""" |
| 915 |
args = CdWriter._buildWriteArgs(hardwareId="0,0,0", imagePath="/dvl/stuff/whatever/more", driveSpeed=1, writeMulti=False) |
| 916 |
self.assertEqual(["-v", "speed=1", "dev=0,0,0", "-data", "/dvl/stuff/whatever/more"], args) |
| 917 |
|
| 918 |
def testBuildArgs_018(self): |
| 919 |
""" |
| 920 |
Test _buildWriteArgs(), 5 for drive speed, False for writeMulti. |
| 921 |
""" |
| 922 |
args = CdWriter._buildWriteArgs(hardwareId="ATA:1,2,3", imagePath="/whatever", driveSpeed=5, writeMulti=False) |
| 923 |
self.assertEqual(["-v", "speed=5", "dev=ATA:1,2,3", "-data", "/whatever"], args) |
| 924 |
|
| 925 |
def testBuildArgs_019(self): |
| 926 |
""" |
| 927 |
Test _buildWriteArgs(), 5 for drive speed, False for writeMulti. |
| 928 |
""" |
| 929 |
args = CdWriter._buildWriteArgs(hardwareId="ATAPI:1,2,3", imagePath="/whatever", driveSpeed=5, writeMulti=False) |
| 930 |
self.assertEqual(["-v", "speed=5", "dev=ATAPI:1,2,3", "-data", "/whatever"], args) |
| 931 |
|
| 932 |
########################################## |
| 933 |
# Test methods that parse cdrecord output |
| 934 |
########################################## |
| 935 |
|
| 936 |
def testParseOutput_001(self): |
| 937 |
""" |
| 938 |
Test _parseBoundariesOutput() for valid data, taken from a real example. |
| 939 |
""" |
| 940 |
output = [ |
| 941 |
"268582,302230\n", |
| 942 |
] |
| 943 |
boundaries = CdWriter._parseBoundariesOutput(output) |
| 944 |
self.assertEqual((268582, 302230), boundaries) |
| 945 |
|
| 946 |
def testParseOutput_002(self): |
| 947 |
""" |
| 948 |
Test _parseBoundariesOutput() for valid data, taken from a real example, |
| 949 |
lots of extra whitespace around the values. |
| 950 |
""" |
| 951 |
output = [ |
| 952 |
" 268582 , 302230 \n", |
| 953 |
] |
| 954 |
boundaries = CdWriter._parseBoundariesOutput(output) |
| 955 |
self.assertEqual((268582, 302230), boundaries) |
| 956 |
|
| 957 |
def testParseOutput_003(self): |
| 958 |
""" |
| 959 |
Test _parseBoundariesOutput() for valid data, taken from a real example, |
| 960 |
lots of extra garbage after the first line. |
| 961 |
""" |
| 962 |
output = [ |
| 963 |
"268582,302230\n", |
| 964 |
"more\n", |
| 965 |
"bogus\n", |
| 966 |
"crap\n", |
| 967 |
"here\n", |
| 968 |
"to\n", |
| 969 |
"confuse\n", |
| 970 |
"things\n", |
| 971 |
] |
| 972 |
boundaries = CdWriter._parseBoundariesOutput(output) |
| 973 |
self.assertEqual((268582, 302230), boundaries) |
| 974 |
|
| 975 |
def testParseOutput_004(self): |
| 976 |
""" |
| 977 |
Test _parseBoundariesOutput() for valid data, taken from a real example, |
| 978 |
lots of extra garbage before the first line. |
| 979 |
""" |
| 980 |
output = [ |
| 981 |
"more\n", |
| 982 |
"bogus\n", |
| 983 |
"crap\n", |
| 984 |
"here\n", |
| 985 |
"to\n", |
| 986 |
"confuse\n", |
| 987 |
"things\n", |
| 988 |
"268582,302230\n", |
| 989 |
] |
| 990 |
self.assertRaises(IOError, CdWriter._parseBoundariesOutput, output) |
| 991 |
|
| 992 |
def testParseOutput_005(self): |
| 993 |
""" |
| 994 |
Test _parseBoundariesOutput() for valid data, taken from a real example, |
| 995 |
with first value converted to negative. |
| 996 |
""" |
| 997 |
output = [ |
| 998 |
"-268582,302230\n", |
| 999 |
] |
| 1000 |
self.assertRaises(IOError, CdWriter._parseBoundariesOutput, output) |
| 1001 |
|
| 1002 |
def testParseOutput_006(self): |
| 1003 |
""" |
| 1004 |
Test _parseBoundariesOutput() for valid data, taken from a real example, |
| 1005 |
with second value converted to negative. |
| 1006 |
""" |
| 1007 |
output = [ |
| 1008 |
"268582,-302230\n", |
| 1009 |
] |
| 1010 |
self.assertRaises(IOError, CdWriter._parseBoundariesOutput, output) |
| 1011 |
|
| 1012 |
def testParseOutput_007(self): |
| 1013 |
""" |
| 1014 |
Test _parseBoundariesOutput() for valid data, taken from a real example, |
| 1015 |
with first value converted to zero. |
| 1016 |
""" |
| 1017 |
output = [ |
| 1018 |
"0,302230\n", |
| 1019 |
] |
| 1020 |
boundaries = CdWriter._parseBoundariesOutput(output) |
| 1021 |
self.assertEqual((0, 302230), boundaries) |
| 1022 |
|
| 1023 |
def testParseOutput_008(self): |
| 1024 |
""" |
| 1025 |
Test _parseBoundariesOutput() for valid data, taken from a real example, |
| 1026 |
with second value converted to zero. |
| 1027 |
""" |
| 1028 |
output = [ |
| 1029 |
"268582,0\n", |
| 1030 |
] |
| 1031 |
boundaries = CdWriter._parseBoundariesOutput(output) |
| 1032 |
self.assertEqual((268582, 0), boundaries) |
| 1033 |
|
| 1034 |
def testParseOutput_009(self): |
| 1035 |
""" |
| 1036 |
Test _parseBoundariesOutput() for valid data, taken from a real example, |
| 1037 |
with first value converted to negative and second value converted to zero. |
| 1038 |
""" |
| 1039 |
output = [ |
| 1040 |
"-268582,0\n", |
| 1041 |
] |
| 1042 |
self.assertRaises(IOError, CdWriter._parseBoundariesOutput, output) |
| 1043 |
|
| 1044 |
def testParseOutput_010(self): |
| 1045 |
""" |
| 1046 |
Test _parseBoundariesOutput() for valid data, taken from a real example, |
| 1047 |
with first value converted to zero and second value converted to negative. |
| 1048 |
""" |
| 1049 |
output = [ |
| 1050 |
"0,-302230\n", |
| 1051 |
] |
| 1052 |
self.assertRaises(IOError, CdWriter._parseBoundariesOutput, output) |
| 1053 |
|
| 1054 |
def testParseOutput_011(self): |
| 1055 |
""" |
| 1056 |
Test _parsePropertiesOutput() for valid data, taken from a real example, |
| 1057 |
including stderr and stdout mixed together. |
| 1058 |
""" |
| 1059 |
output = [ |
| 1060 |
"scsidev: '0,0,0'\n", |
| 1061 |
"scsibus: 0 target: 0 lun: 0\n", |
| 1062 |
"Linux sg driver version: 3.1.22\n", |
| 1063 |
"Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 J\xf6rg Schilling\n", |
| 1064 |
"Using libscg version 'schily-0.5'\n", |
| 1065 |
"Device type : Removable CD-ROM\n", |
| 1066 |
"Version : 0\n", |
| 1067 |
"Response Format: 1\n", |
| 1068 |
"Vendor_info : 'SONY '\n", |
| 1069 |
"Identifikation : 'CD-RW CRX140E '\n", |
| 1070 |
"Revision : '1.0n'\n", |
| 1071 |
"Device seems to be: Generic mmc CD-RW.\n", |
| 1072 |
"\n", |
| 1073 |
"Drive capabilities, per page 2A:\n", |
| 1074 |
"\n", |
| 1075 |
" Does read CD-R media\n", |
| 1076 |
" Does write CD-R media\n", |
| 1077 |
" Does read CD-RW media\n", |
| 1078 |
" Does write CD-RW media\n", |
| 1079 |
" Does not read DVD-ROM media\n", |
| 1080 |
" Does not read DVD-R media\n", |
| 1081 |
" Does not write DVD-R media\n", |
| 1082 |
" Does not read DVD-RAM media\n", |
| 1083 |
" Does not write DVD-RAM media\n", |
| 1084 |
" Does support test writing\n", |
| 1085 |
"\n", |
| 1086 |
" Does read Mode 2 Form 1 blocks\n", |
| 1087 |
" Does read Mode 2 Form 2 blocks\n", |
| 1088 |
" Does read digital audio blocks\n", |
| 1089 |
" Does restart non-streamed digital audio reads accurately\n", |
| 1090 |
" Does not support BURN-Proof (Sanyo)\n", |
| 1091 |
" Does read multi-session CDs\n", |
| 1092 |
" Does read fixed-packet CD media using Method 2\n", |
| 1093 |
" Does not read CD bar code\n", |
| 1094 |
" Does not read R-W subcode information\n", |
| 1095 |
" Does read raw P-W subcode data from lead in\n", |
| 1096 |
" Does return CD media catalog number\n", |
| 1097 |
" Does return CD ISRC information\n", |
| 1098 |
" Does not support C2 error pointers\n", |
| 1099 |
" Does not deliver composite A/V data\n", |
| 1100 |
"\n", |
| 1101 |
" Does play audio CDs\n", |
| 1102 |
" Number of volume control levels: 256\n", |
| 1103 |
" Does support individual volume control setting for each channel\n", |
| 1104 |
" Does support independent mute setting for each channel\n", |
| 1105 |
" Does not support digital output on port 1\n", |
| 1106 |
" Does not support digital output on port 2\n", |
| 1107 |
"\n", |
| 1108 |
" Loading mechanism type: tray\n", |
| 1109 |
" Does support ejection of CD via START/STOP command\n", |
| 1110 |
" Does not lock media on power up via prevent jumper\n", |
| 1111 |
" Does allow media to be locked in the drive via PREVENT/ALLOW command\n", |
| 1112 |
" Is not currently in a media-locked state\n", |
| 1113 |
" Does not support changing side of disk\n", |
| 1114 |
" Does not have load-empty-slot-in-changer feature\n", |
| 1115 |
" Does not support Individual Disk Present feature\n", |
| 1116 |
"\n", |
| 1117 |
" Maximum read speed in kB/s: 5645\n", |
| 1118 |
" Current read speed in kB/s: 3528\n", |
| 1119 |
" Maximum write speed in kB/s: 1411\n", |
| 1120 |
" Current write speed in kB/s: 706\n", |
| 1121 |
" Buffer size in KB: 4096\n", |
| 1122 |
] |
| 1123 |
( |
| 1124 |
deviceType, |
| 1125 |
deviceVendor, |
| 1126 |
deviceId, |
| 1127 |
deviceBufferSize, |
| 1128 |
deviceSupportsMulti, |
| 1129 |
deviceHasTray, |
| 1130 |
deviceCanEject, |
| 1131 |
) = CdWriter._parsePropertiesOutput(output) |
| 1132 |
self.assertEqual("Removable CD-ROM", deviceType) |
| 1133 |
self.assertEqual("SONY", deviceVendor) |
| 1134 |
self.assertEqual("CD-RW CRX140E", deviceId) |
| 1135 |
self.assertEqual(4096.0 * 1024.0, deviceBufferSize) |
| 1136 |
self.assertEqual(True, deviceSupportsMulti) |
| 1137 |
self.assertEqual(True, deviceHasTray) |
| 1138 |
self.assertEqual(True, deviceCanEject) |
| 1139 |
|
| 1140 |
def testParseOutput_012(self): |
| 1141 |
""" |
| 1142 |
Test _parsePropertiesOutput() for valid data, taken from a real example, |
| 1143 |
including only stdout. |
| 1144 |
""" |
| 1145 |
output = [ |
| 1146 |
"Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 J\xf6rg Schilling\n", |
| 1147 |
"Using libscg version 'schily-0.5'\n", |
| 1148 |
"Device type : Removable CD-ROM\n", |
| 1149 |
"Version : 0\n", |
| 1150 |
"Response Format: 1\n", |
| 1151 |
"Vendor_info : 'SONY '\n", |
| 1152 |
"Identifikation : 'CD-RW CRX140E '\n", |
| 1153 |
"Revision : '1.0n'\n", |
| 1154 |
"Device seems to be: Generic mmc CD-RW.\n", |
| 1155 |
"\n", |
| 1156 |
"Drive capabilities, per page 2A:\n", |
| 1157 |
"\n", |
| 1158 |
" Does read CD-R media\n", |
| 1159 |
" Does write CD-R media\n", |
| 1160 |
" Does read CD-RW media\n", |
| 1161 |
" Does write CD-RW media\n", |
| 1162 |
" Does not read DVD-ROM media\n", |
| 1163 |
" Does not read DVD-R media\n", |
| 1164 |
" Does not write DVD-R media\n", |
| 1165 |
" Does not read DVD-RAM media\n", |
| 1166 |
" Does not write DVD-RAM media\n", |
| 1167 |
" Does support test writing\n", |
| 1168 |
"\n", |
| 1169 |
" Does read Mode 2 Form 1 blocks\n", |
| 1170 |
" Does read Mode 2 Form 2 blocks\n", |
| 1171 |
" Does read digital audio blocks\n", |
| 1172 |
" Does restart non-streamed digital audio reads accurately\n", |
| 1173 |
" Does not support BURN-Proof (Sanyo)\n", |
| 1174 |
" Does read multi-session CDs\n", |
| 1175 |
" Does read fixed-packet CD media using Method 2\n", |
| 1176 |
" Does not read CD bar code\n", |
| 1177 |
" Does not read R-W subcode information\n", |
| 1178 |
" Does read raw P-W subcode data from lead in\n", |
| 1179 |
" Does return CD media catalog number\n", |
| 1180 |
" Does return CD ISRC information\n", |
| 1181 |
" Does not support C2 error pointers\n", |
| 1182 |
" Does not deliver composite A/V data\n", |
| 1183 |
"\n", |
| 1184 |
" Does play audio CDs\n", |
| 1185 |
" Number of volume control levels: 256\n", |
| 1186 |
" Does support individual volume control setting for each channel\n", |
| 1187 |
" Does support independent mute setting for each channel\n", |
| 1188 |
" Does not support digital output on port 1\n", |
| 1189 |
" Does not support digital output on port 2\n", |
| 1190 |
"\n", |
| 1191 |
" Loading mechanism type: tray\n", |
| 1192 |
" Does support ejection of CD via START/STOP command\n", |
| 1193 |
" Does not lock media on power up via prevent jumper\n", |
| 1194 |
" Does allow media to be locked in the drive via PREVENT/ALLOW command\n", |
| 1195 |
" Is not currently in a media-locked state\n", |
| 1196 |
" Does not support changing side of disk\n", |
| 1197 |
" Does not have load-empty-slot-in-changer feature\n", |
| 1198 |
" Does not support Individual Disk Present feature\n", |
| 1199 |
"\n", |
| 1200 |
" Maximum read speed in kB/s: 5645\n", |
| 1201 |
" Current read speed in kB/s: 3528\n", |
| 1202 |
" Maximum write speed in kB/s: 1411\n", |
| 1203 |
" Current write speed in kB/s: 706\n", |
| 1204 |
" Buffer size in KB: 4096\n", |
| 1205 |
] |
| 1206 |
( |
| 1207 |
deviceType, |
| 1208 |
deviceVendor, |
| 1209 |
deviceId, |
| 1210 |
deviceBufferSize, |
| 1211 |
deviceSupportsMulti, |
| 1212 |
deviceHasTray, |
| 1213 |
deviceCanEject, |
| 1214 |
) = CdWriter._parsePropertiesOutput(output) |
| 1215 |
self.assertEqual("Removable CD-ROM", deviceType) |
| 1216 |
self.assertEqual("SONY", deviceVendor) |
| 1217 |
self.assertEqual("CD-RW CRX140E", deviceId) |
| 1218 |
self.assertEqual(4096.0 * 1024.0, deviceBufferSize) |
| 1219 |
self.assertEqual(True, deviceSupportsMulti) |
| 1220 |
self.assertEqual(True, deviceHasTray) |
| 1221 |
self.assertEqual(True, deviceCanEject) |
| 1222 |
|
| 1223 |
def testParseOutput_013(self): |
| 1224 |
""" |
| 1225 |
Test _parsePropertiesOutput() for valid data, taken from a real example, |
| 1226 |
including stderr and stdout mixed together, device type removed. |
| 1227 |
""" |
| 1228 |
output = [ |
| 1229 |
"scsidev: '0,0,0'\n", |
| 1230 |
"scsibus: 0 target: 0 lun: 0\n", |
| 1231 |
"Linux sg driver version: 3.1.22\n", |
| 1232 |
"Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 J\xf6rg Schilling\n", |
| 1233 |
"Using libscg version 'schily-0.5'\n", |
| 1234 |
"Version : 0\n", |
| 1235 |
"Response Format: 1\n", |
| 1236 |
"Vendor_info : 'SONY '\n", |
| 1237 |
"Identifikation : 'CD-RW CRX140E '\n", |
| 1238 |
"Revision : '1.0n'\n", |
| 1239 |
"Device seems to be: Generic mmc CD-RW.\n", |
| 1240 |
"\n", |
| 1241 |
"Drive capabilities, per page 2A:\n", |
| 1242 |
"\n", |
| 1243 |
" Does read CD-R media\n", |
| 1244 |
" Does write CD-R media\n", |
| 1245 |
" Does read CD-RW media\n", |
| 1246 |
" Does write CD-RW media\n", |
| 1247 |
" Does not read DVD-ROM media\n", |
| 1248 |
" Does not read DVD-R media\n", |
| 1249 |
" Does not write DVD-R media\n", |
| 1250 |
" Does not read DVD-RAM media\n", |
| 1251 |
" Does not write DVD-RAM media\n", |
| 1252 |
" Does support test writing\n", |
| 1253 |
"\n", |
| 1254 |
" Does read Mode 2 Form 1 blocks\n", |
| 1255 |
" Does read Mode 2 Form 2 blocks\n", |
| 1256 |
" Does read digital audio blocks\n", |
| 1257 |
" Does restart non-streamed digital audio reads accurately\n", |
| 1258 |
" Does not support BURN-Proof (Sanyo)\n", |
| 1259 |
" Does read multi-session CDs\n", |
| 1260 |
" Does read fixed-packet CD media using Method 2\n", |
| 1261 |
" Does not read CD bar code\n", |
| 1262 |
" Does not read R-W subcode information\n", |
| 1263 |
" Does read raw P-W subcode data from lead in\n", |
| 1264 |
" Does return CD media catalog number\n", |
| 1265 |
" Does return CD ISRC information\n", |
| 1266 |
" Does not support C2 error pointers\n", |
| 1267 |
" Does not deliver composite A/V data\n", |
| 1268 |
"\n", |
| 1269 |
" Does play audio CDs\n", |
| 1270 |
" Number of volume control levels: 256\n", |
| 1271 |
" Does support individual volume control setting for each channel\n", |
| 1272 |
" Does support independent mute setting for each channel\n", |
| 1273 |
" Does not support digital output on port 1\n", |
| 1274 |
" Does not support digital output on port 2\n", |
| 1275 |
"\n", |
| 1276 |
" Loading mechanism type: tray\n", |
| 1277 |
" Does support ejection of CD via START/STOP command\n", |
| 1278 |
" Does not lock media on power up via prevent jumper\n", |
| 1279 |
" Does allow media to be locked in the drive via PREVENT/ALLOW command\n", |
| 1280 |
" Is not currently in a media-locked state\n", |
| 1281 |
" Does not support changing side of disk\n", |
| 1282 |
" Does not have load-empty-slot-in-changer feature\n", |
| 1283 |
" Does not support Individual Disk Present feature\n", |
| 1284 |
"\n", |
| 1285 |
" Maximum read speed in kB/s: 5645\n", |
| 1286 |
" Current read speed in kB/s: 3528\n", |
| 1287 |
" Maximum write speed in kB/s: 1411\n", |
| 1288 |
" Current write speed in kB/s: 706\n", |
| 1289 |
" Buffer size in KB: 4096\n", |
| 1290 |
] |
| 1291 |
( |
| 1292 |
deviceType, |
| 1293 |
deviceVendor, |
| 1294 |
deviceId, |
| 1295 |
deviceBufferSize, |
| 1296 |
deviceSupportsMulti, |
| 1297 |
deviceHasTray, |
| 1298 |
deviceCanEject, |
| 1299 |
) = CdWriter._parsePropertiesOutput(output) |
| 1300 |
self.assertEqual(None, deviceType) |
| 1301 |
self.assertEqual("SONY", deviceVendor) |
| 1302 |
self.assertEqual("CD-RW CRX140E", deviceId) |
| 1303 |
self.assertEqual(4096.0 * 1024.0, deviceBufferSize) |
| 1304 |
self.assertEqual(True, deviceSupportsMulti) |
| 1305 |
self.assertEqual(True, deviceHasTray) |
| 1306 |
self.assertEqual(True, deviceCanEject) |
| 1307 |
|
| 1308 |
def testParseOutput_014(self): |
| 1309 |
""" |
| 1310 |
Test _parsePropertiesOutput() for valid data, taken from a real example, |
| 1311 |
including stderr and stdout mixed together, device vendor removed. |
| 1312 |
""" |
| 1313 |
output = [ |
| 1314 |
"scsidev: '0,0,0'\n", |
| 1315 |
"scsibus: 0 target: 0 lun: 0\n", |
| 1316 |
"Linux sg driver version: 3.1.22\n", |
| 1317 |
"Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 J\xf6rg Schilling\n", |
| 1318 |
"Using libscg version 'schily-0.5'\n", |
| 1319 |
"Device type : Removable CD-ROM\n", |
| 1320 |
"Version : 0\n", |
| 1321 |
"Response Format: 1\n", |
| 1322 |
"Identifikation : 'CD-RW CRX140E '\n", |
| 1323 |
"Revision : '1.0n'\n", |
| 1324 |
"Device seems to be: Generic mmc CD-RW.\n", |
| 1325 |
"\n", |
| 1326 |
"Drive capabilities, per page 2A:\n", |
| 1327 |
"\n", |
| 1328 |
" Does read CD-R media\n", |
| 1329 |
" Does write CD-R media\n", |
| 1330 |
" Does read CD-RW media\n", |
| 1331 |
" Does write CD-RW media\n", |
| 1332 |
" Does not read DVD-ROM media\n", |
| 1333 |
" Does not read DVD-R media\n", |
| 1334 |
" Does not write DVD-R media\n", |
| 1335 |
" Does not read DVD-RAM media\n", |
| 1336 |
" Does not write DVD-RAM media\n", |
| 1337 |
" Does support test writing\n", |
| 1338 |
"\n", |
| 1339 |
" Does read Mode 2 Form 1 blocks\n", |
| 1340 |
" Does read Mode 2 Form 2 blocks\n", |
| 1341 |
" Does read digital audio blocks\n", |
| 1342 |
" Does restart non-streamed digital audio reads accurately\n", |
| 1343 |
" Does not support BURN-Proof (Sanyo)\n", |
| 1344 |
" Does read multi-session CDs\n", |
| 1345 |
" Does read fixed-packet CD media using Method 2\n", |
| 1346 |
" Does not read CD bar code\n", |
| 1347 |
" Does not read R-W subcode information\n", |
| 1348 |
" Does read raw P-W subcode data from lead in\n", |
| 1349 |
" Does return CD media catalog number\n", |
| 1350 |
" Does return CD ISRC information\n", |
| 1351 |
" Does not support C2 error pointers\n", |
| 1352 |
" Does not deliver composite A/V data\n", |
| 1353 |
"\n", |
| 1354 |
" Does play audio CDs\n", |
| 1355 |
" Number of volume control levels: 256\n", |
| 1356 |
" Does support individual volume control setting for each channel\n", |
| 1357 |
" Does support independent mute setting for each channel\n", |
| 1358 |
" Does not support digital output on port 1\n", |
| 1359 |
" Does not support digital output on port 2\n", |
| 1360 |
"\n", |
| 1361 |
" Loading mechanism type: tray\n", |
| 1362 |
" Does support ejection of CD via START/STOP command\n", |
| 1363 |
" Does not lock media on power up via prevent jumper\n", |
| 1364 |
" Does allow media to be locked in the drive via PREVENT/ALLOW command\n", |
| 1365 |
" Is not currently in a media-locked state\n", |
| 1366 |
" Does not support changing side of disk\n", |
| 1367 |
" Does not have load-empty-slot-in-changer feature\n", |
| 1368 |
" Does not support Individual Disk Present feature\n", |
| 1369 |
"\n", |
| 1370 |
" Maximum read speed in kB/s: 5645\n", |
| 1371 |
" Current read speed in kB/s: 3528\n", |
| 1372 |
" Maximum write speed in kB/s: 1411\n", |
| 1373 |
" Current write speed in kB/s: 706\n", |
| 1374 |
" Buffer size in KB: 4096\n", |
| 1375 |
] |
| 1376 |
( |
| 1377 |
deviceType, |
| 1378 |
deviceVendor, |
| 1379 |
deviceId, |
| 1380 |
deviceBufferSize, |
| 1381 |
deviceSupportsMulti, |
| 1382 |
deviceHasTray, |
| 1383 |
deviceCanEject, |
| 1384 |
) = CdWriter._parsePropertiesOutput(output) |
| 1385 |
self.assertEqual("Removable CD-ROM", deviceType) |
| 1386 |
self.assertEqual(None, deviceVendor) |
| 1387 |
self.assertEqual("CD-RW CRX140E", deviceId) |
| 1388 |
self.assertEqual(4096.0 * 1024.0, deviceBufferSize) |
| 1389 |
self.assertEqual(True, deviceSupportsMulti) |
| 1390 |
self.assertEqual(True, deviceHasTray) |
| 1391 |
self.assertEqual(True, deviceCanEject) |
| 1392 |
|
| 1393 |
def testParseOutput_015(self): |
| 1394 |
""" |
| 1395 |
Test _parsePropertiesOutput() for valid data, taken from a real example, |
| 1396 |
including stderr and stdout mixed together, device id removed. |
| 1397 |
""" |
| 1398 |
output = [ |
| 1399 |
"scsidev: '0,0,0'\n", |
| 1400 |
"scsibus: 0 target: 0 lun: 0\n", |
| 1401 |
"Linux sg driver version: 3.1.22\n", |
| 1402 |
"Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 J\xf6rg Schilling\n", |
| 1403 |
"Using libscg version 'schily-0.5'\n", |
| 1404 |
"Device type : Removable CD-ROM\n", |
| 1405 |
"Version : 0\n", |
| 1406 |
"Response Format: 1\n", |
| 1407 |
"Vendor_info : 'SONY '\n", |
| 1408 |
"Revision : '1.0n'\n", |
| 1409 |
"Device seems to be: Generic mmc CD-RW.\n", |
| 1410 |
"\n", |
| 1411 |
"Drive capabilities, per page 2A:\n", |
| 1412 |
"\n", |
| 1413 |
" Does read CD-R media\n", |
| 1414 |
" Does write CD-R media\n", |
| 1415 |
" Does read CD-RW media\n", |
| 1416 |
" Does write CD-RW media\n", |
| 1417 |
" Does not read DVD-ROM media\n", |
| 1418 |
" Does not read DVD-R media\n", |
| 1419 |
" Does not write DVD-R media\n", |
| 1420 |
" Does not read DVD-RAM media\n", |
| 1421 |
" Does not write DVD-RAM media\n", |
| 1422 |
" Does support test writing\n", |
| 1423 |
"\n", |
| 1424 |
" Does read Mode 2 Form 1 blocks\n", |
| 1425 |
" Does read Mode 2 Form 2 blocks\n", |
| 1426 |
" Does read digital audio blocks\n", |
| 1427 |
" Does restart non-streamed digital audio reads accurately\n", |
| 1428 |
" Does not support BURN-Proof (Sanyo)\n", |
| 1429 |
" Does read multi-session CDs\n", |
| 1430 |
" Does read fixed-packet CD media using Method 2\n", |
| 1431 |
" Does not read CD bar code\n", |
| 1432 |
" Does not read R-W subcode information\n", |
| 1433 |
" Does read raw P-W subcode data from lead in\n", |
| 1434 |
" Does return CD media catalog number\n", |
| 1435 |
" Does return CD ISRC information\n", |
| 1436 |
" Does not support C2 error pointers\n", |
| 1437 |
" Does not deliver composite A/V data\n", |
| 1438 |
"\n", |
| 1439 |
" Does play audio CDs\n", |
| 1440 |
" Number of volume control levels: 256\n", |
| 1441 |
" Does support individual volume control setting for each channel\n", |
| 1442 |
" Does support independent mute setting for each channel\n", |
| 1443 |
" Does not support digital output on port 1\n", |
| 1444 |
" Does not support digital output on port 2\n", |
| 1445 |
"\n", |
| 1446 |
" Loading mechanism type: tray\n", |
| 1447 |
" Does support ejection of CD via START/STOP command\n", |
| 1448 |
" Does not lock media on power up via prevent jumper\n", |
| 1449 |
" Does allow media to be locked in the drive via PREVENT/ALLOW command\n", |
| 1450 |
" Is not currently in a media-locked state\n", |
| 1451 |
" Does not support changing side of disk\n", |
| 1452 |
" Does not have load-empty-slot-in-changer feature\n", |
| 1453 |
" Does not support Individual Disk Present feature\n", |
| 1454 |
"\n", |
| 1455 |
" Maximum read speed in kB/s: 5645\n", |
| 1456 |
" Current read speed in kB/s: 3528\n", |
| 1457 |
" Maximum write speed in kB/s: 1411\n", |
| 1458 |
" Current write speed in kB/s: 706\n", |
| 1459 |
" Buffer size in KB: 4096\n", |
| 1460 |
] |
| 1461 |
( |
| 1462 |
deviceType, |
| 1463 |
deviceVendor, |
| 1464 |
deviceId, |
| 1465 |
deviceBufferSize, |
| 1466 |
deviceSupportsMulti, |
| 1467 |
deviceHasTray, |
| 1468 |
deviceCanEject, |
| 1469 |
) = CdWriter._parsePropertiesOutput(output) |
| 1470 |
self.assertEqual("Removable CD-ROM", deviceType) |
| 1471 |
self.assertEqual("SONY", deviceVendor) |
| 1472 |
self.assertEqual(None, deviceId) |
| 1473 |
self.assertEqual(4096.0 * 1024.0, deviceBufferSize) |
| 1474 |
self.assertEqual(True, deviceSupportsMulti) |
| 1475 |
self.assertEqual(True, deviceHasTray) |
| 1476 |
self.assertEqual(True, deviceCanEject) |
| 1477 |
|
| 1478 |
def testParseOutput_016(self): |
| 1479 |
""" |
| 1480 |
Test _parsePropertiesOutput() for valid data, taken from a real example, |
| 1481 |
including stderr and stdout mixed together, buffer size removed. |
| 1482 |
""" |
| 1483 |
output = [ |
| 1484 |
"scsidev: '0,0,0'\n", |
| 1485 |
"scsibus: 0 target: 0 lun: 0\n", |
| 1486 |
"Linux sg driver version: 3.1.22\n", |
| 1487 |
"Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 J\xf6rg Schilling\n", |
| 1488 |
"Using libscg version 'schily-0.5'\n", |
| 1489 |
"Device type : Removable CD-ROM\n", |
| 1490 |
"Version : 0\n", |
| 1491 |
"Response Format: 1\n", |
| 1492 |
"Vendor_info : 'SONY '\n", |
| 1493 |
"Identifikation : 'CD-RW CRX140E '\n", |
| 1494 |
"Revision : '1.0n'\n", |
| 1495 |
"Device seems to be: Generic mmc CD-RW.\n", |
| 1496 |
"\n", |
| 1497 |
"Drive capabilities, per page 2A:\n", |
| 1498 |
"\n", |
| 1499 |
" Does read CD-R media\n", |
| 1500 |
" Does write CD-R media\n", |
| 1501 |
" Does read CD-RW media\n", |
| 1502 |
" Does write CD-RW media\n", |
| 1503 |
" Does not read DVD-ROM media\n", |
| 1504 |
" Does not read DVD-R media\n", |
| 1505 |
" Does not write DVD-R media\n", |
| 1506 |
" Does not read DVD-RAM media\n", |
| 1507 |
" Does not write DVD-RAM media\n", |
| 1508 |
" Does support test writing\n", |
| 1509 |
"\n", |
| 1510 |
" Does read Mode 2 Form 1 blocks\n", |
| 1511 |
" Does read Mode 2 Form 2 blocks\n", |
| 1512 |
" Does read digital audio blocks\n", |
| 1513 |
" Does restart non-streamed digital audio reads accurately\n", |
| 1514 |
" Does not support BURN-Proof (Sanyo)\n", |
| 1515 |
" Does read multi-session CDs\n", |
| 1516 |
" Does read fixed-packet CD media using Method 2\n", |
| 1517 |
" Does not read CD bar code\n", |
| 1518 |
" Does not read R-W subcode information\n", |
| 1519 |
" Does read raw P-W subcode data from lead in\n", |
| 1520 |
" Does return CD media catalog number\n", |
| 1521 |
" Does return CD ISRC information\n", |
| 1522 |
" Does not support C2 error pointers\n", |
| 1523 |
" Does not deliver composite A/V data\n", |
| 1524 |
"\n", |
| 1525 |
" Does play audio CDs\n", |
| 1526 |
" Number of volume control levels: 256\n", |
| 1527 |
" Does support individual volume control setting for each channel\n", |
| 1528 |
" Does support independent mute setting for each channel\n", |
| 1529 |
" Does not support digital output on port 1\n", |
| 1530 |
" Does not support digital output on port 2\n", |
| 1531 |
"\n", |
| 1532 |
" Loading mechanism type: tray\n", |
| 1533 |
" Does support ejection of CD via START/STOP command\n", |
| 1534 |
" Does not lock media on power up via prevent jumper\n", |
| 1535 |
" Does allow media to be locked in the drive via PREVENT/ALLOW command\n", |
| 1536 |
" Is not currently in a media-locked state\n", |
| 1537 |
" Does not support changing side of disk\n", |
| 1538 |
" Does not have load-empty-slot-in-changer feature\n", |
| 1539 |
" Does not support Individual Disk Present feature\n", |
| 1540 |
"\n", |
| 1541 |
" Maximum read speed in kB/s: 5645\n", |
| 1542 |
" Current read speed in kB/s: 3528\n", |
| 1543 |
" Maximum write speed in kB/s: 1411\n", |
| 1544 |
" Current write speed in kB/s: 706\n", |
| 1545 |
] |
| 1546 |
( |
| 1547 |
deviceType, |
| 1548 |
deviceVendor, |
| 1549 |
deviceId, |
| 1550 |
deviceBufferSize, |
| 1551 |
deviceSupportsMulti, |
| 1552 |
deviceHasTray, |
| 1553 |
deviceCanEject, |
| 1554 |
) = CdWriter._parsePropertiesOutput(output) |
| 1555 |
self.assertEqual("Removable CD-ROM", deviceType) |
| 1556 |
self.assertEqual("SONY", deviceVendor) |
| 1557 |
self.assertEqual("CD-RW CRX140E", deviceId) |
| 1558 |
self.assertEqual(None, deviceBufferSize) |
| 1559 |
self.assertEqual(True, deviceSupportsMulti) |
| 1560 |
self.assertEqual(True, deviceHasTray) |
| 1561 |
self.assertEqual(True, deviceCanEject) |
| 1562 |
|
| 1563 |
def testParseOutput_017(self): |
| 1564 |
""" |
| 1565 |
Test _parsePropertiesOutput() for valid data, taken from a real example, |
| 1566 |
including stderr and stdout mixed together, "supports multi" removed. |
| 1567 |
""" |
| 1568 |
output = [ |
| 1569 |
"scsidev: '0,0,0'\n", |
| 1570 |
"scsibus: 0 target: 0 lun: 0\n", |
| 1571 |
"Linux sg driver version: 3.1.22\n", |
| 1572 |
"Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 J\xf6rg Schilling\n", |
| 1573 |
"Using libscg version 'schily-0.5'\n", |
| 1574 |
"Device type : Removable CD-ROM\n", |
| 1575 |
"Version : 0\n", |
| 1576 |
"Response Format: 1\n", |
| 1577 |
"Vendor_info : 'SONY '\n", |
| 1578 |
"Identifikation : 'CD-RW CRX140E '\n", |
| 1579 |
"Revision : '1.0n'\n", |
| 1580 |
"Device seems to be: Generic mmc CD-RW.\n", |
| 1581 |
"\n", |
| 1582 |
"Drive capabilities, per page 2A:\n", |
| 1583 |
"\n", |
| 1584 |
" Does read CD-R media\n", |
| 1585 |
" Does write CD-R media\n", |
| 1586 |
" Does read CD-RW media\n", |
| 1587 |
" Does write CD-RW media\n", |
| 1588 |
" Does not read DVD-ROM media\n", |
| 1589 |
" Does not read DVD-R media\n", |
| 1590 |
" Does not write DVD-R media\n", |
| 1591 |
" Does not read DVD-RAM media\n", |
| 1592 |
" Does not write DVD-RAM media\n", |
| 1593 |
" Does support test writing\n", |
| 1594 |
"\n", |
| 1595 |
" Does read Mode 2 Form 1 blocks\n", |
| 1596 |
" Does read Mode 2 Form 2 blocks\n", |
| 1597 |
" Does read digital audio blocks\n", |
| 1598 |
" Does restart non-streamed digital audio reads accurately\n", |
| 1599 |
" Does not support BURN-Proof (Sanyo)\n", |
| 1600 |
" Does read fixed-packet CD media using Method 2\n", |
| 1601 |
" Does not read CD bar code\n", |
| 1602 |
" Does not read R-W subcode information\n", |
| 1603 |
" Does read raw P-W subcode data from lead in\n", |
| 1604 |
" Does return CD media catalog number\n", |
| 1605 |
" Does return CD ISRC information\n", |
| 1606 |
" Does not support C2 error pointers\n", |
| 1607 |
" Does not deliver composite A/V data\n", |
| 1608 |
"\n", |
| 1609 |
" Does play audio CDs\n", |
| 1610 |
" Number of volume control levels: 256\n", |
| 1611 |
" Does support individual volume control setting for each channel\n", |
| 1612 |
" Does support independent mute setting for each channel\n", |
| 1613 |
" Does not support digital output on port 1\n", |
| 1614 |
" Does not support digital output on port 2\n", |
| 1615 |
"\n", |
| 1616 |
" Loading mechanism type: tray\n", |
| 1617 |
" Does support ejection of CD via START/STOP command\n", |
| 1618 |
" Does not lock media on power up via prevent jumper\n", |
| 1619 |
" Does allow media to be locked in the drive via PREVENT/ALLOW command\n", |
| 1620 |
" Is not currently in a media-locked state\n", |
| 1621 |
" Does not support changing side of disk\n", |
| 1622 |
" Does not have load-empty-slot-in-changer feature\n", |
| 1623 |
" Does not support Individual Disk Present feature\n", |
| 1624 |
"\n", |
| 1625 |
" Maximum read speed in kB/s: 5645\n", |
| 1626 |
" Current read speed in kB/s: 3528\n", |
| 1627 |
" Maximum write speed in kB/s: 1411\n", |
| 1628 |
" Current write speed in kB/s: 706\n", |
| 1629 |
" Buffer size in KB: 4096\n", |
| 1630 |
] |
| 1631 |
( |
| 1632 |
deviceType, |
| 1633 |
deviceVendor, |
| 1634 |
deviceId, |
| 1635 |
deviceBufferSize, |
| 1636 |
deviceSupportsMulti, |
| 1637 |
deviceHasTray, |
| 1638 |
deviceCanEject, |
| 1639 |
) = CdWriter._parsePropertiesOutput(output) |
| 1640 |
self.assertEqual("Removable CD-ROM", deviceType) |
| 1641 |
self.assertEqual("SONY", deviceVendor) |
| 1642 |
self.assertEqual("CD-RW CRX140E", deviceId) |
| 1643 |
self.assertEqual(4096.0 * 1024.0, deviceBufferSize) |
| 1644 |
self.assertEqual(False, deviceSupportsMulti) |
| 1645 |
self.assertEqual(True, deviceHasTray) |
| 1646 |
self.assertEqual(True, deviceCanEject) |
| 1647 |
|
| 1648 |
def testParseOutput_018(self): |
| 1649 |
""" |
| 1650 |
Test _parsePropertiesOutput() for valid data, taken from a real example, |
| 1651 |
including stderr and stdout mixed together, "has tray" removed. |
| 1652 |
""" |
| 1653 |
output = [ |
| 1654 |
"scsidev: '0,0,0'\n", |
| 1655 |
"scsibus: 0 target: 0 lun: 0\n", |
| 1656 |
"Linux sg driver version: 3.1.22\n", |
| 1657 |
"Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 J\xf6rg Schilling\n", |
| 1658 |
"Using libscg version 'schily-0.5'\n", |
| 1659 |
"Device type : Removable CD-ROM\n", |
| 1660 |
"Version : 0\n", |
| 1661 |
"Response Format: 1\n", |
| 1662 |
"Vendor_info : 'SONY '\n", |
| 1663 |
"Identifikation : 'CD-RW CRX140E '\n", |
| 1664 |
"Revision : '1.0n'\n", |
| 1665 |
"Device seems to be: Generic mmc CD-RW.\n", |
| 1666 |
"\n", |
| 1667 |
"Drive capabilities, per page 2A:\n", |
| 1668 |
"\n", |
| 1669 |
" Does read CD-R media\n", |
| 1670 |
" Does write CD-R media\n", |
| 1671 |
" Does read CD-RW media\n", |
| 1672 |
" Does write CD-RW media\n", |
| 1673 |
" Does not read DVD-ROM media\n", |
| 1674 |
" Does not read DVD-R media\n", |
| 1675 |
" Does not write DVD-R media\n", |
| 1676 |
" Does not read DVD-RAM media\n", |
| 1677 |
" Does not write DVD-RAM media\n", |
| 1678 |
" Does support test writing\n", |
| 1679 |
"\n", |
| 1680 |
" Does read Mode 2 Form 1 blocks\n", |
| 1681 |
" Does read Mode 2 Form 2 blocks\n", |
| 1682 |
" Does read digital audio blocks\n", |
| 1683 |
" Does restart non-streamed digital audio reads accurately\n", |
| 1684 |
" Does not support BURN-Proof (Sanyo)\n", |
| 1685 |
" Does read multi-session CDs\n", |
| 1686 |
" Does read fixed-packet CD media using Method 2\n", |
| 1687 |
" Does not read CD bar code\n", |
| 1688 |
" Does not read R-W subcode information\n", |
| 1689 |
" Does read raw P-W subcode data from lead in\n", |
| 1690 |
" Does return CD media catalog number\n", |
| 1691 |
" Does return CD ISRC information\n", |
| 1692 |
" Does not support C2 error pointers\n", |
| 1693 |
" Does not deliver composite A/V data\n", |
| 1694 |
"\n", |
| 1695 |
" Does play audio CDs\n", |
| 1696 |
" Number of volume control levels: 256\n", |
| 1697 |
" Does support individual volume control setting for each channel\n", |
| 1698 |
" Does support independent mute setting for each channel\n", |
| 1699 |
" Does not support digital output on port 1\n", |
| 1700 |
" Does not support digital output on port 2\n", |
| 1701 |
"\n", |
| 1702 |
" Does support ejection of CD via START/STOP command\n", |
| 1703 |
" Does not lock media on power up via prevent jumper\n", |
| 1704 |
" Does allow media to be locked in the drive via PREVENT/ALLOW command\n", |
| 1705 |
" Is not currently in a media-locked state\n", |
| 1706 |
" Does not support changing side of disk\n", |
| 1707 |
" Does not have load-empty-slot-in-changer feature\n", |
| 1708 |
" Does not support Individual Disk Present feature\n", |
| 1709 |
"\n", |
| 1710 |
" Maximum read speed in kB/s: 5645\n", |
| 1711 |
" Current read speed in kB/s: 3528\n", |
| 1712 |
" Maximum write speed in kB/s: 1411\n", |
| 1713 |
" Current write speed in kB/s: 706\n", |
| 1714 |
" Buffer size in KB: 4096\n", |
| 1715 |
] |
| 1716 |
( |
| 1717 |
deviceType, |
| 1718 |
deviceVendor, |
| 1719 |
deviceId, |
| 1720 |
deviceBufferSize, |
| 1721 |
deviceSupportsMulti, |
| 1722 |
deviceHasTray, |
| 1723 |
deviceCanEject, |
| 1724 |
) = CdWriter._parsePropertiesOutput(output) |
| 1725 |
self.assertEqual("Removable CD-ROM", deviceType) |
| 1726 |
self.assertEqual("SONY", deviceVendor) |
| 1727 |
self.assertEqual("CD-RW CRX140E", deviceId) |
| 1728 |
self.assertEqual(4096.0 * 1024.0, deviceBufferSize) |
| 1729 |
self.assertEqual(True, deviceSupportsMulti) |
| 1730 |
self.assertEqual(False, deviceHasTray) |
| 1731 |
self.assertEqual(True, deviceCanEject) |
| 1732 |
|
| 1733 |
def testParseOutput_019(self): |
| 1734 |
""" |
| 1735 |
Test _parsePropertiesOutput() for valid data, taken from a real example, |
| 1736 |
including stderr and stdout mixed together, "can eject" removed. |
| 1737 |
""" |
| 1738 |
output = [ |
| 1739 |
"scsidev: '0,0,0'\n", |
| 1740 |
"scsibus: 0 target: 0 lun: 0\n", |
| 1741 |
"Linux sg driver version: 3.1.22\n", |
| 1742 |
"Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 J\xf6rg Schilling\n", |
| 1743 |
"Using libscg version 'schily-0.5'\n", |
| 1744 |
"Device type : Removable CD-ROM\n", |
| 1745 |
"Version : 0\n", |
| 1746 |
"Response Format: 1\n", |
| 1747 |
"Vendor_info : 'SONY '\n", |
| 1748 |
"Identifikation : 'CD-RW CRX140E '\n", |
| 1749 |
"Revision : '1.0n'\n", |
| 1750 |
"Device seems to be: Generic mmc CD-RW.\n", |
| 1751 |
"\n", |
| 1752 |
"Drive capabilities, per page 2A:\n", |
| 1753 |
"\n", |
| 1754 |
" Does read CD-R media\n", |
| 1755 |
" Does write CD-R media\n", |
| 1756 |
" Does read CD-RW media\n", |
| 1757 |
" Does write CD-RW media\n", |
| 1758 |
" Does not read DVD-ROM media\n", |
| 1759 |
" Does not read DVD-R media\n", |
| 1760 |
" Does not write DVD-R media\n", |
| 1761 |
" Does not read DVD-RAM media\n", |
| 1762 |
" Does not write DVD-RAM media\n", |
| 1763 |
" Does support test writing\n", |
| 1764 |
"\n", |
| 1765 |
" Does read Mode 2 Form 1 blocks\n", |
| 1766 |
" Does read Mode 2 Form 2 blocks\n", |
| 1767 |
" Does read digital audio blocks\n", |
| 1768 |
" Does restart non-streamed digital audio reads accurately\n", |
| 1769 |
" Does not support BURN-Proof (Sanyo)\n", |
| 1770 |
" Does read multi-session CDs\n", |
| 1771 |
" Does read fixed-packet CD media using Method 2\n", |
| 1772 |
" Does not read CD bar code\n", |
| 1773 |
" Does not read R-W subcode information\n", |
| 1774 |
" Does read raw P-W subcode data from lead in\n", |
| 1775 |
" Does return CD media catalog number\n", |
| 1776 |
" Does return CD ISRC information\n", |
| 1777 |
" Does not support C2 error pointers\n", |
| 1778 |
" Does not deliver composite A/V data\n", |
| 1779 |
"\n", |
| 1780 |
" Does play audio CDs\n", |
| 1781 |
" Number of volume control levels: 256\n", |
| 1782 |
" Does support individual volume control setting for each channel\n", |
| 1783 |
" Does support independent mute setting for each channel\n", |
| 1784 |
" Does not support digital output on port 1\n", |
| 1785 |
" Does not support digital output on port 2\n", |
| 1786 |
"\n", |
| 1787 |
" Loading mechanism type: tray\n", |
| 1788 |
" Does not lock media on power up via prevent jumper\n", |
| 1789 |
" Does allow media to be locked in the drive via PREVENT/ALLOW command\n", |
| 1790 |
" Is not currently in a media-locked state\n", |
| 1791 |
" Does not support changing side of disk\n", |
| 1792 |
" Does not have load-empty-slot-in-changer feature\n", |
| 1793 |
" Does not support Individual Disk Present feature\n", |
| 1794 |
"\n", |
| 1795 |
" Maximum read speed in kB/s: 5645\n", |
| 1796 |
" Current read speed in kB/s: 3528\n", |
| 1797 |
" Maximum write speed in kB/s: 1411\n", |
| 1798 |
" Current write speed in kB/s: 706\n", |
| 1799 |
" Buffer size in KB: 4096\n", |
| 1800 |
] |
| 1801 |
( |
| 1802 |
deviceType, |
| 1803 |
deviceVendor, |
| 1804 |
deviceId, |
| 1805 |
deviceBufferSize, |
| 1806 |
deviceSupportsMulti, |
| 1807 |
deviceHasTray, |
| 1808 |
deviceCanEject, |
| 1809 |
) = CdWriter._parsePropertiesOutput(output) |
| 1810 |
self.assertEqual("Removable CD-ROM", deviceType) |
| 1811 |
self.assertEqual("SONY", deviceVendor) |
| 1812 |
self.assertEqual("CD-RW CRX140E", deviceId) |
| 1813 |
self.assertEqual(4096.0 * 1024.0, deviceBufferSize) |
| 1814 |
self.assertEqual(True, deviceSupportsMulti) |
| 1815 |
self.assertEqual(True, deviceHasTray) |
| 1816 |
self.assertEqual(False, deviceCanEject) |
| 1817 |
|
| 1818 |
def testParseOutput_020(self): |
| 1819 |
""" |
| 1820 |
Test _parsePropertiesOutput() for nonsensical data, just a bunch of empty |
| 1821 |
lines. |
| 1822 |
""" |
| 1823 |
output = [ |
| 1824 |
"\n", |
| 1825 |
"\n", |
| 1826 |
"\n", |
| 1827 |
"\n", |
| 1828 |
"\n", |
| 1829 |
"\n", |
| 1830 |
"\n", |
| 1831 |
"\n", |
| 1832 |
"\n", |
| 1833 |
"\n", |
| 1834 |
"\n", |
| 1835 |
"\n", |
| 1836 |
"\n", |
| 1837 |
"\n", |
| 1838 |
"\n", |
| 1839 |
] |
| 1840 |
( |
| 1841 |
deviceType, |
| 1842 |
deviceVendor, |
| 1843 |
deviceId, |
| 1844 |
deviceBufferSize, |
| 1845 |
deviceSupportsMulti, |
| 1846 |
deviceHasTray, |
| 1847 |
deviceCanEject, |
| 1848 |
) = CdWriter._parsePropertiesOutput(output) |
| 1849 |
self.assertEqual(None, deviceType) |
| 1850 |
self.assertEqual(None, deviceVendor) |
| 1851 |
self.assertEqual(None, deviceId) |
| 1852 |
self.assertEqual(None, deviceBufferSize) |
| 1853 |
self.assertEqual(False, deviceSupportsMulti) |
| 1854 |
self.assertEqual(False, deviceHasTray) |
| 1855 |
self.assertEqual(False, deviceCanEject) |
| 1856 |
|
| 1857 |
def testParseOutput_021(self): |
| 1858 |
""" |
| 1859 |
Test _parsePropertiesOutput() for nonsensical data, just an empty list. |
| 1860 |
""" |
| 1861 |
output = [] |
| 1862 |
( |
| 1863 |
deviceType, |
| 1864 |
deviceVendor, |
| 1865 |
deviceId, |
| 1866 |
deviceBufferSize, |
| 1867 |
deviceSupportsMulti, |
| 1868 |
deviceHasTray, |
| 1869 |
deviceCanEject, |
| 1870 |
) = CdWriter._parsePropertiesOutput(output) |
| 1871 |
self.assertEqual(None, deviceType) |
| 1872 |
self.assertEqual(None, deviceVendor) |
| 1873 |
self.assertEqual(None, deviceId) |
| 1874 |
self.assertEqual(None, deviceBufferSize) |
| 1875 |
self.assertEqual(False, deviceSupportsMulti) |
| 1876 |
self.assertEqual(False, deviceHasTray) |
| 1877 |
self.assertEqual(False, deviceCanEject) |