| 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) 2014-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 amazons3 extension functionality. |
| 30 |
# |
| 31 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
| 32 |
|
| 33 |
######################################################################## |
| 34 |
# Module documentation |
| 35 |
######################################################################## |
| 36 |
|
| 37 |
""" |
| 38 |
Unit tests for CedarBackup3/extend/amazons3.py. |
| 39 |
|
| 40 |
Code Coverage |
| 41 |
============= |
| 42 |
|
| 43 |
This module contains individual tests for the the public classes implemented |
| 44 |
in extend/amazons3.py. There are also tests for some of the private |
| 45 |
functions. |
| 46 |
|
| 47 |
Naming Conventions |
| 48 |
================== |
| 49 |
|
| 50 |
I prefer to avoid large unit tests which validate more than one piece of |
| 51 |
functionality, and I prefer to avoid using overly descriptive (read: long) |
| 52 |
test names, as well. Instead, I use lots of very small tests that each |
| 53 |
validate one specific thing. These small tests are then named with an index |
| 54 |
number, yielding something like ``testAddDir_001`` or ``testValidate_010``. |
| 55 |
Each method has a docstring describing what it's supposed to accomplish. I |
| 56 |
feel that this makes it easier to judge how important a given failure is, |
| 57 |
and also makes it somewhat easier to diagnose and fix individual problems. |
| 58 |
|
| 59 |
Testing XML Extraction |
| 60 |
====================== |
| 61 |
|
| 62 |
It's difficult to validated that generated XML is exactly "right", |
| 63 |
especially when dealing with pretty-printed XML. We can't just provide a |
| 64 |
constant string and say "the result must match this". Instead, what we do |
| 65 |
is extract a node, build some XML from it, and then feed that XML back into |
| 66 |
another object's constructor. If that parse process succeeds and the old |
| 67 |
object is equal to the new object, we assume that the extract was |
| 68 |
successful. |
| 69 |
|
| 70 |
It would arguably be better if we could do a completely independent check - |
| 71 |
but implementing that check would be equivalent to re-implementing all of |
| 72 |
the existing functionality that we're validating here! After all, the most |
| 73 |
important thing is that data can move seamlessly from object to XML document |
| 74 |
and back to object. |
| 75 |
|
| 76 |
@author Kenneth J. Pronovici <[email protected]> |
| 77 |
""" |
| 78 |
|
| 79 |
|
| 80 |
######################################################################## |
| 81 |
# Import modules and do runtime validations |
| 82 |
######################################################################## |
| 83 |
|
| 84 |
import tempfile |
| 85 |
import unittest |
| 86 |
|
| 87 |
from CedarBackup3.config import ByteQuantity |
| 88 |
from CedarBackup3.extend.amazons3 import AmazonS3Config, LocalConfig |
| 89 |
from CedarBackup3.testutil import ( |
| 90 |
buildPath, |
| 91 |
configureLogging, |
| 92 |
extractTar, |
| 93 |
failUnlessAssignRaises, |
| 94 |
findResources, |
| 95 |
platformMacOsX, |
| 96 |
removedir, |
| 97 |
) |
| 98 |
from CedarBackup3.tools.amazons3 import _buildSourceFiles, _checkSourceFiles |
| 99 |
from CedarBackup3.util import UNIT_BYTES, UNIT_GBYTES, UNIT_MBYTES |
| 100 |
from CedarBackup3.xmlutil import createOutputDom, serializeDom |
| 101 |
|
| 102 |
####################################################################### |
| 103 |
# Module-wide configuration and constants |
| 104 |
####################################################################### |
| 105 |
|
| 106 |
DATA_DIRS = [ |
| 107 |
"./data", |
| 108 |
"./tests/data", |
| 109 |
] |
| 110 |
RESOURCES = [ |
| 111 |
"amazons3.conf.1", |
| 112 |
"amazons3.conf.2", |
| 113 |
"amazons3.conf.3", |
| 114 |
"tree1.tar.gz", |
| 115 |
"tree2.tar.gz", |
| 116 |
"tree4.tar.gz", |
| 117 |
"tree8.tar.gz", |
| 118 |
"tree13.tar.gz", |
| 119 |
"tree15.tar.gz", |
| 120 |
"tree16.tar.gz", |
| 121 |
"tree17.tar.gz", |
| 122 |
"tree18.tar.gz", |
| 123 |
"tree19.tar.gz", |
| 124 |
"tree20.tar.gz", |
| 125 |
] |
| 126 |
|
| 127 |
|
| 128 |
####################################################################### |
| 129 |
# Test Case Classes |
| 130 |
####################################################################### |
| 131 |
|
| 132 |
########################## |
| 133 |
# TestAmazonS3Config class |
| 134 |
########################## |
| 135 |
|
| 136 |
|
| 137 |
class TestAmazonS3Config(unittest.TestCase): |
| 138 |
"""Tests for the AmazonS3Config class.""" |
| 139 |
|
| 140 |
################ |
| 141 |
# Setup methods |
| 142 |
################ |
| 143 |
|
| 144 |
@classmethod |
| 145 |
def setUpClass(cls): |
| 146 |
configureLogging() |
| 147 |
|
| 148 |
################## |
| 149 |
# Utility methods |
| 150 |
################## |
| 151 |
|
| 152 |
def failUnlessAssignRaises(self, exception, obj, prop, value): |
| 153 |
"""Equivalent of :any:`failUnlessRaises`, but used for property assignments instead.""" |
| 154 |
failUnlessAssignRaises(self, exception, obj, prop, value) |
| 155 |
|
| 156 |
############################ |
| 157 |
# Test __repr__ and __str__ |
| 158 |
############################ |
| 159 |
|
| 160 |
def testStringFuncs_001(self): |
| 161 |
""" |
| 162 |
Just make sure that the string functions don't have errors (i.e. bad variable names). |
| 163 |
""" |
| 164 |
obj = AmazonS3Config() |
| 165 |
obj.__repr__() |
| 166 |
obj.__str__() |
| 167 |
|
| 168 |
################################## |
| 169 |
# Test constructor and attributes |
| 170 |
################################## |
| 171 |
|
| 172 |
def testConstructor_001(self): |
| 173 |
""" |
| 174 |
Test constructor with no values filled in. |
| 175 |
""" |
| 176 |
amazons3 = AmazonS3Config() |
| 177 |
self.assertEqual(False, amazons3.warnMidnite) |
| 178 |
self.assertEqual(None, amazons3.s3Bucket) |
| 179 |
self.assertEqual(None, amazons3.encryptCommand) |
| 180 |
self.assertEqual(None, amazons3.fullBackupSizeLimit) |
| 181 |
self.assertEqual(None, amazons3.incrementalBackupSizeLimit) |
| 182 |
|
| 183 |
def testConstructor_002a(self): |
| 184 |
""" |
| 185 |
Test constructor with all values filled in, with valid values (integers). |
| 186 |
""" |
| 187 |
amazons3 = AmazonS3Config(True, "bucket", "encrypt", 1, 2) |
| 188 |
self.assertEqual(True, amazons3.warnMidnite) |
| 189 |
self.assertEqual("bucket", amazons3.s3Bucket) |
| 190 |
self.assertEqual("encrypt", amazons3.encryptCommand) |
| 191 |
self.assertEqual(1, amazons3.fullBackupSizeLimit) |
| 192 |
self.assertEqual(2, amazons3.incrementalBackupSizeLimit) |
| 193 |
self.assertEqual(ByteQuantity(1, UNIT_BYTES), amazons3.fullBackupSizeLimit) |
| 194 |
self.assertEqual(ByteQuantity(2, UNIT_BYTES), amazons3.incrementalBackupSizeLimit) |
| 195 |
|
| 196 |
def testConstructor_002b(self): |
| 197 |
""" |
| 198 |
Test constructor with all values filled in, with valid values (byte quantities). |
| 199 |
""" |
| 200 |
amazons3 = AmazonS3Config(True, "bucket", "encrypt", ByteQuantity(1, UNIT_BYTES), ByteQuantity(2, UNIT_BYTES)) |
| 201 |
self.assertEqual(True, amazons3.warnMidnite) |
| 202 |
self.assertEqual("bucket", amazons3.s3Bucket) |
| 203 |
self.assertEqual("encrypt", amazons3.encryptCommand) |
| 204 |
self.assertEqual(ByteQuantity(1, UNIT_BYTES), amazons3.fullBackupSizeLimit) |
| 205 |
self.assertEqual(ByteQuantity(2, UNIT_BYTES), amazons3.incrementalBackupSizeLimit) |
| 206 |
|
| 207 |
def testConstructor_003(self): |
| 208 |
""" |
| 209 |
Test assignment of warnMidnite attribute, valid value (real boolean). |
| 210 |
""" |
| 211 |
amazons3 = AmazonS3Config() |
| 212 |
self.assertEqual(False, amazons3.warnMidnite) |
| 213 |
amazons3.warnMidnite = True |
| 214 |
self.assertEqual(True, amazons3.warnMidnite) |
| 215 |
amazons3.warnMidnite = False |
| 216 |
self.assertEqual(False, amazons3.warnMidnite) |
| 217 |
|
| 218 |
def testConstructor_004(self): |
| 219 |
""" |
| 220 |
Test assignment of warnMidnite attribute, valid value (expression). |
| 221 |
""" |
| 222 |
amazons3 = AmazonS3Config() |
| 223 |
self.assertEqual(False, amazons3.warnMidnite) |
| 224 |
amazons3.warnMidnite = 0 |
| 225 |
self.assertEqual(False, amazons3.warnMidnite) |
| 226 |
amazons3.warnMidnite = [] |
| 227 |
self.assertEqual(False, amazons3.warnMidnite) |
| 228 |
amazons3.warnMidnite = None |
| 229 |
self.assertEqual(False, amazons3.warnMidnite) |
| 230 |
amazons3.warnMidnite = ["a"] |
| 231 |
self.assertEqual(True, amazons3.warnMidnite) |
| 232 |
amazons3.warnMidnite = 3 |
| 233 |
self.assertEqual(True, amazons3.warnMidnite) |
| 234 |
|
| 235 |
def testConstructor_005(self): |
| 236 |
""" |
| 237 |
Test assignment of s3Bucket attribute, None value. |
| 238 |
""" |
| 239 |
amazons3 = AmazonS3Config(s3Bucket="bucket") |
| 240 |
self.assertEqual("bucket", amazons3.s3Bucket) |
| 241 |
amazons3.s3Bucket = None |
| 242 |
self.assertEqual(None, amazons3.s3Bucket) |
| 243 |
|
| 244 |
def testConstructor_006(self): |
| 245 |
""" |
| 246 |
Test assignment of s3Bucket attribute, valid value. |
| 247 |
""" |
| 248 |
amazons3 = AmazonS3Config() |
| 249 |
self.assertEqual(None, amazons3.s3Bucket) |
| 250 |
amazons3.s3Bucket = "bucket" |
| 251 |
self.assertEqual("bucket", amazons3.s3Bucket) |
| 252 |
|
| 253 |
def testConstructor_007(self): |
| 254 |
""" |
| 255 |
Test assignment of s3Bucket attribute, invalid value (empty). |
| 256 |
""" |
| 257 |
amazons3 = AmazonS3Config() |
| 258 |
self.assertEqual(None, amazons3.s3Bucket) |
| 259 |
self.failUnlessAssignRaises(ValueError, amazons3, "s3Bucket", "") |
| 260 |
self.assertEqual(None, amazons3.s3Bucket) |
| 261 |
|
| 262 |
def testConstructor_008(self): |
| 263 |
""" |
| 264 |
Test assignment of encryptCommand attribute, None value. |
| 265 |
""" |
| 266 |
amazons3 = AmazonS3Config(encryptCommand="encrypt") |
| 267 |
self.assertEqual("encrypt", amazons3.encryptCommand) |
| 268 |
amazons3.encryptCommand = None |
| 269 |
self.assertEqual(None, amazons3.encryptCommand) |
| 270 |
|
| 271 |
def testConstructor_009(self): |
| 272 |
""" |
| 273 |
Test assignment of encryptCommand attribute, valid value. |
| 274 |
""" |
| 275 |
amazons3 = AmazonS3Config() |
| 276 |
self.assertEqual(None, amazons3.encryptCommand) |
| 277 |
amazons3.encryptCommand = "encrypt" |
| 278 |
self.assertEqual("encrypt", amazons3.encryptCommand) |
| 279 |
|
| 280 |
def testConstructor_010(self): |
| 281 |
""" |
| 282 |
Test assignment of encryptCommand attribute, invalid value (empty). |
| 283 |
""" |
| 284 |
amazons3 = AmazonS3Config() |
| 285 |
self.assertEqual(None, amazons3.encryptCommand) |
| 286 |
self.failUnlessAssignRaises(ValueError, amazons3, "encryptCommand", "") |
| 287 |
self.assertEqual(None, amazons3.encryptCommand) |
| 288 |
|
| 289 |
def testConstructor_011(self): |
| 290 |
""" |
| 291 |
Test assignment of fullBackupSizeLimit attribute, None value. |
| 292 |
""" |
| 293 |
amazons3 = AmazonS3Config(fullBackupSizeLimit=100) |
| 294 |
self.assertEqual(100, amazons3.fullBackupSizeLimit) |
| 295 |
amazons3.fullBackupSizeLimit = None |
| 296 |
self.assertEqual(None, amazons3.fullBackupSizeLimit) |
| 297 |
|
| 298 |
def testConstructor_012a(self): |
| 299 |
""" |
| 300 |
Test assignment of fullBackupSizeLimit attribute, valid int value. |
| 301 |
""" |
| 302 |
amazons3 = AmazonS3Config() |
| 303 |
self.assertEqual(None, amazons3.fullBackupSizeLimit) |
| 304 |
amazons3.fullBackupSizeLimit = 15 |
| 305 |
self.assertEqual(15, amazons3.fullBackupSizeLimit) |
| 306 |
self.assertEqual(ByteQuantity(15, UNIT_BYTES), amazons3.fullBackupSizeLimit) |
| 307 |
|
| 308 |
def testConstructor_012b(self): |
| 309 |
""" |
| 310 |
Test assignment of fullBackupSizeLimit attribute, valid long value. |
| 311 |
""" |
| 312 |
amazons3 = AmazonS3Config() |
| 313 |
self.assertEqual(None, amazons3.fullBackupSizeLimit) |
| 314 |
amazons3.fullBackupSizeLimit = 7516192768 |
| 315 |
self.assertEqual(7516192768, amazons3.fullBackupSizeLimit) |
| 316 |
self.assertEqual(ByteQuantity(7516192768, UNIT_BYTES), amazons3.fullBackupSizeLimit) |
| 317 |
|
| 318 |
def testConstructor_012c(self): |
| 319 |
""" |
| 320 |
Test assignment of fullBackupSizeLimit attribute, valid float value. |
| 321 |
""" |
| 322 |
amazons3 = AmazonS3Config() |
| 323 |
self.assertEqual(None, amazons3.fullBackupSizeLimit) |
| 324 |
amazons3.fullBackupSizeLimit = 7516192768.0 |
| 325 |
self.assertEqual(7516192768.0, amazons3.fullBackupSizeLimit) |
| 326 |
self.assertEqual(ByteQuantity(7516192768.0, UNIT_BYTES), amazons3.fullBackupSizeLimit) |
| 327 |
|
| 328 |
def testConstructor_012d(self): |
| 329 |
""" |
| 330 |
Test assignment of fullBackupSizeLimit attribute, valid string value. |
| 331 |
""" |
| 332 |
amazons3 = AmazonS3Config() |
| 333 |
self.assertEqual(None, amazons3.fullBackupSizeLimit) |
| 334 |
amazons3.fullBackupSizeLimit = "7516192768" |
| 335 |
self.assertEqual(7516192768, amazons3.fullBackupSizeLimit) |
| 336 |
self.assertEqual(ByteQuantity("7516192768", UNIT_BYTES), amazons3.fullBackupSizeLimit) |
| 337 |
|
| 338 |
def testConstructor_012e(self): |
| 339 |
""" |
| 340 |
Test assignment of fullBackupSizeLimit attribute, valid byte quantity value. |
| 341 |
""" |
| 342 |
amazons3 = AmazonS3Config() |
| 343 |
self.assertEqual(None, amazons3.fullBackupSizeLimit) |
| 344 |
amazons3.fullBackupSizeLimit = ByteQuantity(2.5, UNIT_GBYTES) |
| 345 |
self.assertEqual(ByteQuantity(2.5, UNIT_GBYTES), amazons3.fullBackupSizeLimit) |
| 346 |
self.assertEqual(2684354560.0, amazons3.fullBackupSizeLimit.bytes) |
| 347 |
|
| 348 |
def testConstructor_012f(self): |
| 349 |
""" |
| 350 |
Test assignment of fullBackupSizeLimit attribute, valid byte quantity value. |
| 351 |
""" |
| 352 |
amazons3 = AmazonS3Config() |
| 353 |
self.assertEqual(None, amazons3.fullBackupSizeLimit) |
| 354 |
amazons3.fullBackupSizeLimit = ByteQuantity(600, UNIT_MBYTES) |
| 355 |
self.assertEqual(ByteQuantity(600, UNIT_MBYTES), amazons3.fullBackupSizeLimit) |
| 356 |
self.assertEqual(629145600.0, amazons3.fullBackupSizeLimit.bytes) |
| 357 |
|
| 358 |
def testConstructor_013(self): |
| 359 |
""" |
| 360 |
Test assignment of fullBackupSizeLimit attribute, invalid value. |
| 361 |
""" |
| 362 |
amazons3 = AmazonS3Config() |
| 363 |
self.assertEqual(None, amazons3.fullBackupSizeLimit) |
| 364 |
self.failUnlessAssignRaises(ValueError, amazons3, "fullBackupSizeLimit", "xxx") |
| 365 |
self.assertEqual(None, amazons3.fullBackupSizeLimit) |
| 366 |
|
| 367 |
def testConstructor_014(self): |
| 368 |
""" |
| 369 |
Test assignment of incrementalBackupSizeLimit attribute, None value. |
| 370 |
""" |
| 371 |
amazons3 = AmazonS3Config(incrementalBackupSizeLimit=100) |
| 372 |
self.assertEqual(100, amazons3.incrementalBackupSizeLimit) |
| 373 |
amazons3.incrementalBackupSizeLimit = None |
| 374 |
self.assertEqual(None, amazons3.incrementalBackupSizeLimit) |
| 375 |
|
| 376 |
def testConstructor_015a(self): |
| 377 |
""" |
| 378 |
Test assignment of incrementalBackupSizeLimit attribute, valid int value. |
| 379 |
""" |
| 380 |
amazons3 = AmazonS3Config() |
| 381 |
self.assertEqual(None, amazons3.incrementalBackupSizeLimit) |
| 382 |
amazons3.incrementalBackupSizeLimit = 15 |
| 383 |
self.assertEqual(15, amazons3.incrementalBackupSizeLimit) |
| 384 |
self.assertEqual(ByteQuantity(15, UNIT_BYTES), amazons3.incrementalBackupSizeLimit) |
| 385 |
|
| 386 |
def testConstructor_015b(self): |
| 387 |
""" |
| 388 |
Test assignment of incrementalBackupSizeLimit attribute, valid long value. |
| 389 |
""" |
| 390 |
amazons3 = AmazonS3Config() |
| 391 |
self.assertEqual(None, amazons3.incrementalBackupSizeLimit) |
| 392 |
amazons3.incrementalBackupSizeLimit = 7516192768 |
| 393 |
self.assertEqual(7516192768, amazons3.incrementalBackupSizeLimit) |
| 394 |
self.assertEqual(ByteQuantity(7516192768, UNIT_BYTES), amazons3.incrementalBackupSizeLimit) |
| 395 |
|
| 396 |
def testConstructor_015c(self): |
| 397 |
""" |
| 398 |
Test assignment of incrementalBackupSizeLimit attribute, valid float value. |
| 399 |
""" |
| 400 |
amazons3 = AmazonS3Config() |
| 401 |
self.assertEqual(None, amazons3.incrementalBackupSizeLimit) |
| 402 |
amazons3.incrementalBackupSizeLimit = 7516192768.0 |
| 403 |
self.assertEqual(7516192768.0, amazons3.incrementalBackupSizeLimit) |
| 404 |
self.assertEqual(ByteQuantity(7516192768.0, UNIT_BYTES), amazons3.incrementalBackupSizeLimit) |
| 405 |
|
| 406 |
def testConstructor_015d(self): |
| 407 |
""" |
| 408 |
Test assignment of incrementalBackupSizeLimit attribute, valid string value. |
| 409 |
""" |
| 410 |
amazons3 = AmazonS3Config() |
| 411 |
self.assertEqual(None, amazons3.incrementalBackupSizeLimit) |
| 412 |
amazons3.incrementalBackupSizeLimit = "7516192768" |
| 413 |
self.assertEqual(7516192768, amazons3.incrementalBackupSizeLimit) |
| 414 |
self.assertEqual(ByteQuantity("7516192768", UNIT_BYTES), amazons3.incrementalBackupSizeLimit) |
| 415 |
|
| 416 |
def testConstructor_015e(self): |
| 417 |
""" |
| 418 |
Test assignment of incrementalBackupSizeLimit attribute, valid byte quantity value. |
| 419 |
""" |
| 420 |
amazons3 = AmazonS3Config() |
| 421 |
self.assertEqual(None, amazons3.incrementalBackupSizeLimit) |
| 422 |
amazons3.incrementalBackupSizeLimit = ByteQuantity(2.5, UNIT_GBYTES) |
| 423 |
self.assertEqual(ByteQuantity(2.5, UNIT_GBYTES), amazons3.incrementalBackupSizeLimit) |
| 424 |
self.assertEqual(2684354560.0, amazons3.incrementalBackupSizeLimit.bytes) |
| 425 |
|
| 426 |
def testConstructor_015f(self): |
| 427 |
""" |
| 428 |
Test assignment of incrementalBackupSizeLimit attribute, valid byte quantity value. |
| 429 |
""" |
| 430 |
amazons3 = AmazonS3Config() |
| 431 |
self.assertEqual(None, amazons3.incrementalBackupSizeLimit) |
| 432 |
amazons3.incrementalBackupSizeLimit = ByteQuantity(600, UNIT_MBYTES) |
| 433 |
self.assertEqual(ByteQuantity(600, UNIT_MBYTES), amazons3.incrementalBackupSizeLimit) |
| 434 |
self.assertEqual(629145600.0, amazons3.incrementalBackupSizeLimit.bytes) |
| 435 |
|
| 436 |
def testConstructor_016(self): |
| 437 |
""" |
| 438 |
Test assignment of incrementalBackupSizeLimit attribute, invalid value. |
| 439 |
""" |
| 440 |
amazons3 = AmazonS3Config() |
| 441 |
self.assertEqual(None, amazons3.incrementalBackupSizeLimit) |
| 442 |
self.failUnlessAssignRaises(ValueError, amazons3, "incrementalBackupSizeLimit", "xxx") |
| 443 |
self.assertEqual(None, amazons3.incrementalBackupSizeLimit) |
| 444 |
|
| 445 |
############################ |
| 446 |
# Test comparison operators |
| 447 |
############################ |
| 448 |
|
| 449 |
def testComparison_001(self): |
| 450 |
""" |
| 451 |
Test comparison of two identical objects, all attributes None. |
| 452 |
""" |
| 453 |
amazons31 = AmazonS3Config() |
| 454 |
amazons32 = AmazonS3Config() |
| 455 |
self.assertEqual(amazons31, amazons32) |
| 456 |
self.assertTrue(amazons31 == amazons32) |
| 457 |
self.assertTrue(not amazons31 < amazons32) |
| 458 |
self.assertTrue(amazons31 <= amazons32) |
| 459 |
self.assertTrue(not amazons31 > amazons32) |
| 460 |
self.assertTrue(amazons31 >= amazons32) |
| 461 |
self.assertTrue(not amazons31 != amazons32) |
| 462 |
|
| 463 |
def testComparison_002(self): |
| 464 |
""" |
| 465 |
Test comparison of two identical objects, all attributes non-None. |
| 466 |
""" |
| 467 |
amazons31 = AmazonS3Config(True, "bucket", "encrypt", 1, 2) |
| 468 |
amazons32 = AmazonS3Config(True, "bucket", "encrypt", 1, 2) |
| 469 |
self.assertEqual(amazons31, amazons32) |
| 470 |
self.assertTrue(amazons31 == amazons32) |
| 471 |
self.assertTrue(not amazons31 < amazons32) |
| 472 |
self.assertTrue(amazons31 <= amazons32) |
| 473 |
self.assertTrue(not amazons31 > amazons32) |
| 474 |
self.assertTrue(amazons31 >= amazons32) |
| 475 |
self.assertTrue(not amazons31 != amazons32) |
| 476 |
|
| 477 |
def testComparison_003(self): |
| 478 |
""" |
| 479 |
Test comparison of two differing objects, warnMidnite differs. |
| 480 |
""" |
| 481 |
amazons31 = AmazonS3Config(warnMidnite=False) |
| 482 |
amazons32 = AmazonS3Config(warnMidnite=True) |
| 483 |
self.assertNotEqual(amazons31, amazons32) |
| 484 |
self.assertTrue(not amazons31 == amazons32) |
| 485 |
self.assertTrue(amazons31 < amazons32) |
| 486 |
self.assertTrue(amazons31 <= amazons32) |
| 487 |
self.assertTrue(not amazons31 > amazons32) |
| 488 |
self.assertTrue(not amazons31 >= amazons32) |
| 489 |
self.assertTrue(amazons31 != amazons32) |
| 490 |
|
| 491 |
def testComparison_004(self): |
| 492 |
""" |
| 493 |
Test comparison of two differing objects, s3Bucket differs (one None). |
| 494 |
""" |
| 495 |
amazons31 = AmazonS3Config() |
| 496 |
amazons32 = AmazonS3Config(s3Bucket="bucket") |
| 497 |
self.assertNotEqual(amazons31, amazons32) |
| 498 |
self.assertTrue(not amazons31 == amazons32) |
| 499 |
self.assertTrue(amazons31 < amazons32) |
| 500 |
self.assertTrue(amazons31 <= amazons32) |
| 501 |
self.assertTrue(not amazons31 > amazons32) |
| 502 |
self.assertTrue(not amazons31 >= amazons32) |
| 503 |
self.assertTrue(amazons31 != amazons32) |
| 504 |
|
| 505 |
def testComparison_005(self): |
| 506 |
""" |
| 507 |
Test comparison of two differing objects, s3Bucket differs. |
| 508 |
""" |
| 509 |
amazons31 = AmazonS3Config(s3Bucket="bucket1") |
| 510 |
amazons32 = AmazonS3Config(s3Bucket="bucket2") |
| 511 |
self.assertNotEqual(amazons31, amazons32) |
| 512 |
self.assertTrue(not amazons31 == amazons32) |
| 513 |
self.assertTrue(amazons31 < amazons32) |
| 514 |
self.assertTrue(amazons31 <= amazons32) |
| 515 |
self.assertTrue(not amazons31 > amazons32) |
| 516 |
self.assertTrue(not amazons31 >= amazons32) |
| 517 |
self.assertTrue(amazons31 != amazons32) |
| 518 |
|
| 519 |
def testComparison_006(self): |
| 520 |
""" |
| 521 |
Test comparison of two differing objects, encryptCommand differs (one None). |
| 522 |
""" |
| 523 |
amazons31 = AmazonS3Config() |
| 524 |
amazons32 = AmazonS3Config(encryptCommand="encrypt") |
| 525 |
self.assertNotEqual(amazons31, amazons32) |
| 526 |
self.assertTrue(not amazons31 == amazons32) |
| 527 |
self.assertTrue(amazons31 < amazons32) |
| 528 |
self.assertTrue(amazons31 <= amazons32) |
| 529 |
self.assertTrue(not amazons31 > amazons32) |
| 530 |
self.assertTrue(not amazons31 >= amazons32) |
| 531 |
self.assertTrue(amazons31 != amazons32) |
| 532 |
|
| 533 |
def testComparison_007(self): |
| 534 |
""" |
| 535 |
Test comparison of two differing objects, encryptCommand differs. |
| 536 |
""" |
| 537 |
amazons31 = AmazonS3Config(encryptCommand="encrypt1") |
| 538 |
amazons32 = AmazonS3Config(encryptCommand="encrypt2") |
| 539 |
self.assertNotEqual(amazons31, amazons32) |
| 540 |
self.assertTrue(not amazons31 == amazons32) |
| 541 |
self.assertTrue(amazons31 < amazons32) |
| 542 |
self.assertTrue(amazons31 <= amazons32) |
| 543 |
self.assertTrue(not amazons31 > amazons32) |
| 544 |
self.assertTrue(not amazons31 >= amazons32) |
| 545 |
self.assertTrue(amazons31 != amazons32) |
| 546 |
|
| 547 |
def testComparison_008(self): |
| 548 |
""" |
| 549 |
Test comparison of two differing objects, fullBackupSizeLimit differs (one None). |
| 550 |
""" |
| 551 |
amazons31 = AmazonS3Config() |
| 552 |
amazons32 = AmazonS3Config(fullBackupSizeLimit=1) |
| 553 |
self.assertNotEqual(amazons31, amazons32) |
| 554 |
self.assertTrue(not amazons31 == amazons32) |
| 555 |
self.assertTrue(amazons31 < amazons32) |
| 556 |
self.assertTrue(amazons31 <= amazons32) |
| 557 |
self.assertTrue(not amazons31 > amazons32) |
| 558 |
self.assertTrue(not amazons31 >= amazons32) |
| 559 |
self.assertTrue(amazons31 != amazons32) |
| 560 |
|
| 561 |
def testComparison_009(self): |
| 562 |
""" |
| 563 |
Test comparison of two differing objects, fullBackupSizeLimit differs. |
| 564 |
""" |
| 565 |
amazons31 = AmazonS3Config(fullBackupSizeLimit=1) |
| 566 |
amazons32 = AmazonS3Config(fullBackupSizeLimit=2) |
| 567 |
self.assertNotEqual(amazons31, amazons32) |
| 568 |
self.assertTrue(not amazons31 == amazons32) |
| 569 |
self.assertTrue(amazons31 < amazons32) |
| 570 |
self.assertTrue(amazons31 <= amazons32) |
| 571 |
self.assertTrue(not amazons31 > amazons32) |
| 572 |
self.assertTrue(not amazons31 >= amazons32) |
| 573 |
self.assertTrue(amazons31 != amazons32) |
| 574 |
|
| 575 |
def testComparison_010(self): |
| 576 |
""" |
| 577 |
Test comparison of two differing objects, incrementalBackupSizeLimit differs (one None). |
| 578 |
""" |
| 579 |
amazons31 = AmazonS3Config() |
| 580 |
amazons32 = AmazonS3Config(incrementalBackupSizeLimit=1) |
| 581 |
self.assertNotEqual(amazons31, amazons32) |
| 582 |
self.assertTrue(not amazons31 == amazons32) |
| 583 |
self.assertTrue(amazons31 < amazons32) |
| 584 |
self.assertTrue(amazons31 <= amazons32) |
| 585 |
self.assertTrue(not amazons31 > amazons32) |
| 586 |
self.assertTrue(not amazons31 >= amazons32) |
| 587 |
self.assertTrue(amazons31 != amazons32) |
| 588 |
|
| 589 |
def testComparison_011(self): |
| 590 |
""" |
| 591 |
Test comparison of two differing objects, incrementalBackupSizeLimit differs. |
| 592 |
""" |
| 593 |
amazons31 = AmazonS3Config(incrementalBackupSizeLimit=1) |
| 594 |
amazons32 = AmazonS3Config(incrementalBackupSizeLimit=2) |
| 595 |
self.assertNotEqual(amazons31, amazons32) |
| 596 |
self.assertTrue(not amazons31 == amazons32) |
| 597 |
self.assertTrue(amazons31 < amazons32) |
| 598 |
self.assertTrue(amazons31 <= amazons32) |
| 599 |
self.assertTrue(not amazons31 > amazons32) |
| 600 |
self.assertTrue(not amazons31 >= amazons32) |
| 601 |
self.assertTrue(amazons31 != amazons32) |
| 602 |
|
| 603 |
|
| 604 |
######################## |
| 605 |
# TestLocalConfig class |
| 606 |
######################## |
| 607 |
|
| 608 |
|
| 609 |
class TestLocalConfig(unittest.TestCase): |
| 610 |
"""Tests for the LocalConfig class.""" |
| 611 |
|
| 612 |
################ |
| 613 |
# Setup methods |
| 614 |
################ |
| 615 |
|
| 616 |
@classmethod |
| 617 |
def setUpClass(cls): |
| 618 |
configureLogging() |
| 619 |
|
| 620 |
def setUp(self): |
| 621 |
try: |
| 622 |
self.resources = findResources(RESOURCES, DATA_DIRS) |
| 623 |
except Exception as e: |
| 624 |
self.fail(e) |
| 625 |
|
| 626 |
def tearDown(self): |
| 627 |
pass |
| 628 |
|
| 629 |
################## |
| 630 |
# Utility methods |
| 631 |
################## |
| 632 |
|
| 633 |
def failUnlessAssignRaises(self, exception, obj, prop, value): |
| 634 |
"""Equivalent of :any:`failUnlessRaises`, but used for property assignments instead.""" |
| 635 |
failUnlessAssignRaises(self, exception, obj, prop, value) |
| 636 |
|
| 637 |
def validateAddConfig(self, origConfig): |
| 638 |
""" |
| 639 |
Validates that document dumped from ``LocalConfig.addConfig`` results in |
| 640 |
identical object. |
| 641 |
|
| 642 |
We dump a document containing just the amazons3 configuration, and then |
| 643 |
make sure that if we push that document back into the ``LocalConfig`` |
| 644 |
object, that the resulting object matches the original. |
| 645 |
|
| 646 |
The ``self.failUnlessEqual`` method is used for the validation, so if the |
| 647 |
method call returns normally, everything is OK. |
| 648 |
|
| 649 |
Args: |
| 650 |
origConfig: Original configuration |
| 651 |
""" |
| 652 |
(xmlDom, parentNode) = createOutputDom() |
| 653 |
origConfig.addConfig(xmlDom, parentNode) |
| 654 |
xmlData = serializeDom(xmlDom) |
| 655 |
newConfig = LocalConfig(xmlData=xmlData, validate=False) |
| 656 |
self.assertEqual(origConfig, newConfig) |
| 657 |
|
| 658 |
############################ |
| 659 |
# Test __repr__ and __str__ |
| 660 |
############################ |
| 661 |
|
| 662 |
def testStringFuncs_001(self): |
| 663 |
""" |
| 664 |
Just make sure that the string functions don't have errors (i.e. bad variable names). |
| 665 |
""" |
| 666 |
obj = LocalConfig() |
| 667 |
obj.__repr__() |
| 668 |
obj.__str__() |
| 669 |
|
| 670 |
##################################################### |
| 671 |
# Test basic constructor and attribute functionality |
| 672 |
##################################################### |
| 673 |
|
| 674 |
def testConstructor_001(self): |
| 675 |
""" |
| 676 |
Test empty constructor, validate=False. |
| 677 |
""" |
| 678 |
config = LocalConfig(validate=False) |
| 679 |
self.assertEqual(None, config.amazons3) |
| 680 |
|
| 681 |
def testConstructor_002(self): |
| 682 |
""" |
| 683 |
Test empty constructor, validate=True. |
| 684 |
""" |
| 685 |
config = LocalConfig(validate=True) |
| 686 |
self.assertEqual(None, config.amazons3) |
| 687 |
|
| 688 |
def testConstructor_003(self): |
| 689 |
""" |
| 690 |
Test with empty config document as both data and file, validate=False. |
| 691 |
""" |
| 692 |
path = self.resources["amazons3.conf.1"] |
| 693 |
with open(path) as f: |
| 694 |
contents = f.read() |
| 695 |
self.assertRaises(ValueError, LocalConfig, xmlData=contents, xmlPath=path, validate=False) |
| 696 |
|
| 697 |
def testConstructor_004(self): |
| 698 |
""" |
| 699 |
Test assignment of amazons3 attribute, None value. |
| 700 |
""" |
| 701 |
config = LocalConfig() |
| 702 |
config.amazons3 = None |
| 703 |
self.assertEqual(None, config.amazons3) |
| 704 |
|
| 705 |
def testConstructor_005(self): |
| 706 |
""" |
| 707 |
Test assignment of amazons3 attribute, valid value. |
| 708 |
""" |
| 709 |
config = LocalConfig() |
| 710 |
config.amazons3 = AmazonS3Config() |
| 711 |
self.assertEqual(AmazonS3Config(), config.amazons3) |
| 712 |
|
| 713 |
def testConstructor_006(self): |
| 714 |
""" |
| 715 |
Test assignment of amazons3 attribute, invalid value (not AmazonS3Config). |
| 716 |
""" |
| 717 |
config = LocalConfig() |
| 718 |
self.failUnlessAssignRaises(ValueError, config, "amazons3", "STRING!") |
| 719 |
|
| 720 |
############################ |
| 721 |
# Test comparison operators |
| 722 |
############################ |
| 723 |
|
| 724 |
def testComparison_001(self): |
| 725 |
""" |
| 726 |
Test comparison of two identical objects, all attributes None. |
| 727 |
""" |
| 728 |
config1 = LocalConfig() |
| 729 |
config2 = LocalConfig() |
| 730 |
self.assertEqual(config1, config2) |
| 731 |
self.assertTrue(config1 == config2) |
| 732 |
self.assertTrue(not config1 < config2) |
| 733 |
self.assertTrue(config1 <= config2) |
| 734 |
self.assertTrue(not config1 > config2) |
| 735 |
self.assertTrue(config1 >= config2) |
| 736 |
self.assertTrue(not config1 != config2) |
| 737 |
|
| 738 |
def testComparison_002(self): |
| 739 |
""" |
| 740 |
Test comparison of two identical objects, all attributes non-None. |
| 741 |
""" |
| 742 |
config1 = LocalConfig() |
| 743 |
config1.amazons3 = AmazonS3Config() |
| 744 |
|
| 745 |
config2 = LocalConfig() |
| 746 |
config2.amazons3 = AmazonS3Config() |
| 747 |
|
| 748 |
self.assertEqual(config1, config2) |
| 749 |
self.assertTrue(config1 == config2) |
| 750 |
self.assertTrue(not config1 < config2) |
| 751 |
self.assertTrue(config1 <= config2) |
| 752 |
self.assertTrue(not config1 > config2) |
| 753 |
self.assertTrue(config1 >= config2) |
| 754 |
self.assertTrue(not config1 != config2) |
| 755 |
|
| 756 |
def testComparison_003(self): |
| 757 |
""" |
| 758 |
Test comparison of two differing objects, amazons3 differs (one None). |
| 759 |
""" |
| 760 |
config1 = LocalConfig() |
| 761 |
config2 = LocalConfig() |
| 762 |
config2.amazons3 = AmazonS3Config() |
| 763 |
self.assertNotEqual(config1, config2) |
| 764 |
self.assertTrue(not config1 == config2) |
| 765 |
self.assertTrue(config1 < config2) |
| 766 |
self.assertTrue(config1 <= config2) |
| 767 |
self.assertTrue(not config1 > config2) |
| 768 |
self.assertTrue(not config1 >= config2) |
| 769 |
self.assertTrue(config1 != config2) |
| 770 |
|
| 771 |
def testComparison_004(self): |
| 772 |
""" |
| 773 |
Test comparison of two differing objects, s3Bucket differs. |
| 774 |
""" |
| 775 |
config1 = LocalConfig() |
| 776 |
config1.amazons3 = AmazonS3Config(True, "bucket1", "encrypt", 1, 2) |
| 777 |
|
| 778 |
config2 = LocalConfig() |
| 779 |
config2.amazons3 = AmazonS3Config(True, "bucket2", "encrypt", 1, 2) |
| 780 |
|
| 781 |
self.assertNotEqual(config1, config2) |
| 782 |
self.assertTrue(not config1 == config2) |
| 783 |
self.assertTrue(config1 < config2) |
| 784 |
self.assertTrue(config1 <= config2) |
| 785 |
self.assertTrue(not config1 > config2) |
| 786 |
self.assertTrue(not config1 >= config2) |
| 787 |
self.assertTrue(config1 != config2) |
| 788 |
|
| 789 |
###################### |
| 790 |
# Test validate logic |
| 791 |
###################### |
| 792 |
|
| 793 |
def testValidate_001(self): |
| 794 |
""" |
| 795 |
Test validate on a None amazons3 section. |
| 796 |
""" |
| 797 |
config = LocalConfig() |
| 798 |
config.amazons3 = None |
| 799 |
self.assertRaises(ValueError, config.validate) |
| 800 |
|
| 801 |
def testValidate_002(self): |
| 802 |
""" |
| 803 |
Test validate on an empty amazons3 section. |
| 804 |
""" |
| 805 |
config = LocalConfig() |
| 806 |
config.amazons3 = AmazonS3Config() |
| 807 |
self.assertRaises(ValueError, config.validate) |
| 808 |
|
| 809 |
def testValidate_003(self): |
| 810 |
""" |
| 811 |
Test validate on a non-empty amazons3 section with no values filled in. |
| 812 |
""" |
| 813 |
config = LocalConfig() |
| 814 |
config.amazons3 = AmazonS3Config(None) |
| 815 |
self.assertRaises(ValueError, config.validate) |
| 816 |
|
| 817 |
def testValidate_005(self): |
| 818 |
""" |
| 819 |
Test validate on a non-empty amazons3 section with valid values filled in. |
| 820 |
""" |
| 821 |
config = LocalConfig() |
| 822 |
config.amazons3 = AmazonS3Config(True, "bucket") |
| 823 |
config.validate() |
| 824 |
|
| 825 |
############################ |
| 826 |
# Test parsing of documents |
| 827 |
############################ |
| 828 |
|
| 829 |
def testParse_001(self): |
| 830 |
""" |
| 831 |
Parse empty config document. |
| 832 |
""" |
| 833 |
path = self.resources["amazons3.conf.1"] |
| 834 |
with open(path) as f: |
| 835 |
contents = f.read() |
| 836 |
self.assertRaises(ValueError, LocalConfig, xmlPath=path, validate=True) |
| 837 |
self.assertRaises(ValueError, LocalConfig, xmlData=contents, validate=True) |
| 838 |
config = LocalConfig(xmlPath=path, validate=False) |
| 839 |
self.assertEqual(None, config.amazons3) |
| 840 |
config = LocalConfig(xmlData=contents, validate=False) |
| 841 |
self.assertEqual(None, config.amazons3) |
| 842 |
|
| 843 |
def testParse_002(self): |
| 844 |
""" |
| 845 |
Parse config document with filled-in values. |
| 846 |
""" |
| 847 |
path = self.resources["amazons3.conf.2"] |
| 848 |
with open(path) as f: |
| 849 |
contents = f.read() |
| 850 |
config = LocalConfig(xmlPath=path, validate=False) |
| 851 |
self.assertNotEqual(None, config.amazons3) |
| 852 |
self.assertEqual(True, config.amazons3.warnMidnite) |
| 853 |
self.assertEqual("mybucket", config.amazons3.s3Bucket) |
| 854 |
self.assertEqual("encrypt", config.amazons3.encryptCommand) |
| 855 |
self.assertEqual(5368709120, config.amazons3.fullBackupSizeLimit) |
| 856 |
self.assertEqual(2147483648, config.amazons3.incrementalBackupSizeLimit) |
| 857 |
config = LocalConfig(xmlData=contents, validate=False) |
| 858 |
self.assertNotEqual(None, config.amazons3) |
| 859 |
self.assertEqual(True, config.amazons3.warnMidnite) |
| 860 |
self.assertEqual("mybucket", config.amazons3.s3Bucket) |
| 861 |
self.assertEqual("encrypt", config.amazons3.encryptCommand) |
| 862 |
self.assertEqual(5368709120, config.amazons3.fullBackupSizeLimit) |
| 863 |
self.assertEqual(2147483648, config.amazons3.incrementalBackupSizeLimit) |
| 864 |
|
| 865 |
def testParse_003(self): |
| 866 |
""" |
| 867 |
Parse config document with filled-in values. |
| 868 |
""" |
| 869 |
path = self.resources["amazons3.conf.3"] |
| 870 |
with open(path) as f: |
| 871 |
contents = f.read() |
| 872 |
config = LocalConfig(xmlPath=path, validate=False) |
| 873 |
self.assertNotEqual(None, config.amazons3) |
| 874 |
self.assertEqual(True, config.amazons3.warnMidnite) |
| 875 |
self.assertEqual("mybucket", config.amazons3.s3Bucket) |
| 876 |
self.assertEqual("encrypt", config.amazons3.encryptCommand) |
| 877 |
self.assertEqual(ByteQuantity(2.5, UNIT_GBYTES), config.amazons3.fullBackupSizeLimit) |
| 878 |
self.assertEqual(ByteQuantity(600, UNIT_MBYTES), config.amazons3.incrementalBackupSizeLimit) |
| 879 |
config = LocalConfig(xmlData=contents, validate=False) |
| 880 |
self.assertNotEqual(None, config.amazons3) |
| 881 |
self.assertEqual(True, config.amazons3.warnMidnite) |
| 882 |
self.assertEqual("mybucket", config.amazons3.s3Bucket) |
| 883 |
self.assertEqual("encrypt", config.amazons3.encryptCommand) |
| 884 |
self.assertEqual(ByteQuantity(2.5, UNIT_GBYTES), config.amazons3.fullBackupSizeLimit) |
| 885 |
self.assertEqual(ByteQuantity(600, UNIT_MBYTES), config.amazons3.incrementalBackupSizeLimit) |
| 886 |
|
| 887 |
################### |
| 888 |
# Test addConfig() |
| 889 |
################### |
| 890 |
|
| 891 |
def testAddConfig_001(self): |
| 892 |
""" |
| 893 |
Test with empty config document. |
| 894 |
""" |
| 895 |
amazons3 = AmazonS3Config() |
| 896 |
config = LocalConfig() |
| 897 |
config.amazons3 = amazons3 |
| 898 |
self.validateAddConfig(config) |
| 899 |
|
| 900 |
def testAddConfig_002(self): |
| 901 |
""" |
| 902 |
Test with values set. |
| 903 |
""" |
| 904 |
amazons3 = AmazonS3Config(True, "bucket", "encrypt", 1, 2) |
| 905 |
config = LocalConfig() |
| 906 |
config.amazons3 = amazons3 |
| 907 |
self.validateAddConfig(config) |
| 908 |
|
| 909 |
|
| 910 |
################# |
| 911 |
# TestTool class |
| 912 |
################# |
| 913 |
|
| 914 |
|
| 915 |
class TestTool(unittest.TestCase): |
| 916 |
################ |
| 917 |
# Setup methods |
| 918 |
################ |
| 919 |
|
| 920 |
@classmethod |
| 921 |
def setUpClass(cls): |
| 922 |
configureLogging() |
| 923 |
|
| 924 |
def setUp(self): |
| 925 |
try: |
| 926 |
self.tmpdir = tempfile.mkdtemp() |
| 927 |
self.resources = findResources(RESOURCES, DATA_DIRS) |
| 928 |
except Exception as e: |
| 929 |
self.fail(e) |
| 930 |
|
| 931 |
def tearDown(self): |
| 932 |
try: |
| 933 |
removedir(self.tmpdir) |
| 934 |
except: |
| 935 |
pass |
| 936 |
|
| 937 |
################## |
| 938 |
# Utility methods |
| 939 |
################## |
| 940 |
|
| 941 |
def extractTar(self, tarname): |
| 942 |
"""Extracts a tarfile with a particular name.""" |
| 943 |
extractTar(self.tmpdir, self.resources["%s.tar.gz" % tarname]) |
| 944 |
|
| 945 |
def buildPath(self, components): |
| 946 |
"""Builds a complete search path from a list of components.""" |
| 947 |
components.insert(0, self.tmpdir) |
| 948 |
return buildPath(components) |
| 949 |
|
| 950 |
########################### |
| 951 |
# Test _checkSourceFiles() |
| 952 |
########################### |
| 953 |
|
| 954 |
def testCheckSourceFiles_001(self): |
| 955 |
""" |
| 956 |
Test _checkSourceFiles() where some files have an invalid encoding. |
| 957 |
""" |
| 958 |
if not platformMacOsX(): |
| 959 |
self.extractTar("tree13") |
| 960 |
sourceDir = self.buildPath(["tree13"]) |
| 961 |
sourceFiles = _buildSourceFiles(sourceDir) |
| 962 |
self.assertRaises(ValueError, _checkSourceFiles, sourceDir=sourceDir, sourceFiles=sourceFiles) |
| 963 |
|
| 964 |
def testCheckSourceFiles_002(self): |
| 965 |
""" |
| 966 |
Test _checkSourceFiles() where all files have a valid encoding. |
| 967 |
""" |
| 968 |
self.extractTar("tree4") |
| 969 |
sourceDir = self.buildPath(["tree4", "dir006"]) |
| 970 |
sourceFiles = _buildSourceFiles(sourceDir) |
| 971 |
_checkSourceFiles(sourceDir=sourceDir, sourceFiles=sourceFiles) |