| 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) 2005-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 Subversion extension functionality. |
| 30 |
# |
| 31 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
| 32 |
|
| 33 |
######################################################################## |
| 34 |
# Module documentation |
| 35 |
######################################################################## |
| 36 |
|
| 37 |
""" |
| 38 |
Unit tests for CedarBackup3/extend/subversion.py. |
| 39 |
|
| 40 |
Code Coverage |
| 41 |
============= |
| 42 |
|
| 43 |
This module contains individual tests for the many of the public functions |
| 44 |
and classes implemented in extend/subversion.py. There are also tests for |
| 45 |
several of the private methods. |
| 46 |
|
| 47 |
Unfortunately, it's rather difficult to test this code in an automated |
| 48 |
fashion, even if you have access to Subversion, since the actual backup |
| 49 |
would need to have access to real Subversion repositories. Because of this, |
| 50 |
there aren't any tests below that actually back up repositories. |
| 51 |
|
| 52 |
As a compromise, I test some of the private methods in the implementation. |
| 53 |
Normally, I don't like to test private methods, but in this case, testing |
| 54 |
the private methods will help give us some reasonable confidence in the code |
| 55 |
even if we can't talk to Subversion successfully. This isn't perfect, but |
| 56 |
it's better than nothing. |
| 57 |
|
| 58 |
Naming Conventions |
| 59 |
================== |
| 60 |
|
| 61 |
I prefer to avoid large unit tests which validate more than one piece of |
| 62 |
functionality, and I prefer to avoid using overly descriptive (read: long) |
| 63 |
test names, as well. Instead, I use lots of very small tests that each |
| 64 |
validate one specific thing. These small tests are then named with an index |
| 65 |
number, yielding something like ``testAddDir_001`` or ``testValidate_010``. |
| 66 |
Each method has a docstring describing what it's supposed to accomplish. I |
| 67 |
feel that this makes it easier to judge how important a given failure is, |
| 68 |
and also makes it somewhat easier to diagnose and fix individual problems. |
| 69 |
|
| 70 |
Testing XML Extraction |
| 71 |
====================== |
| 72 |
|
| 73 |
It's difficult to validated that generated XML is exactly "right", |
| 74 |
especially when dealing with pretty-printed XML. We can't just provide a |
| 75 |
constant string and say "the result must match this". Instead, what we do |
| 76 |
is extract a node, build some XML from it, and then feed that XML back into |
| 77 |
another object's constructor. If that parse process succeeds and the old |
| 78 |
object is equal to the new object, we assume that the extract was |
| 79 |
successful. |
| 80 |
|
| 81 |
It would arguably be better if we could do a completely independent check - |
| 82 |
but implementing that check would be equivalent to re-implementing all of |
| 83 |
the existing functionality that we're validating here! After all, the most |
| 84 |
important thing is that data can move seamlessly from object to XML document |
| 85 |
and back to object. |
| 86 |
|
| 87 |
Full vs. Reduced Tests |
| 88 |
====================== |
| 89 |
|
| 90 |
All of the tests in this module are considered safe to be run in an average |
| 91 |
build environment. There is a no need to use a SUBVERSIONTESTS_FULL |
| 92 |
environment variable to provide a "reduced feature set" test suite as for |
| 93 |
some of the other test modules. |
| 94 |
|
| 95 |
@author Kenneth J. Pronovici <[email protected]> |
| 96 |
""" |
| 97 |
|
| 98 |
|
| 99 |
######################################################################## |
| 100 |
# Import modules and do runtime validations |
| 101 |
######################################################################## |
| 102 |
|
| 103 |
import unittest |
| 104 |
|
| 105 |
from CedarBackup3.extend.subversion import BDBRepository, FSFSRepository, LocalConfig, Repository, RepositoryDir, SubversionConfig |
| 106 |
from CedarBackup3.testutil import configureLogging, failUnlessAssignRaises, findResources |
| 107 |
from CedarBackup3.xmlutil import createOutputDom, serializeDom |
| 108 |
|
| 109 |
####################################################################### |
| 110 |
# Module-wide configuration and constants |
| 111 |
####################################################################### |
| 112 |
|
| 113 |
DATA_DIRS = [ |
| 114 |
"./data", |
| 115 |
"./tests/data", |
| 116 |
] |
| 117 |
RESOURCES = [ |
| 118 |
"subversion.conf.1", |
| 119 |
"subversion.conf.2", |
| 120 |
"subversion.conf.3", |
| 121 |
"subversion.conf.4", |
| 122 |
"subversion.conf.5", |
| 123 |
"subversion.conf.6", |
| 124 |
"subversion.conf.7", |
| 125 |
] |
| 126 |
|
| 127 |
|
| 128 |
####################################################################### |
| 129 |
# Test Case Classes |
| 130 |
####################################################################### |
| 131 |
|
| 132 |
########################## |
| 133 |
# TestBDBRepository class |
| 134 |
########################## |
| 135 |
|
| 136 |
|
| 137 |
class TestBDBRepository(unittest.TestCase): |
| 138 |
""" |
| 139 |
Tests for the BDBRepository class. |
| 140 |
|
| 141 |
*Note:* This class is deprecated. These tests are kept around to make sure |
| 142 |
that we don't accidentally break the interface. |
| 143 |
""" |
| 144 |
|
| 145 |
################ |
| 146 |
# Setup methods |
| 147 |
################ |
| 148 |
|
| 149 |
@classmethod |
| 150 |
def setUpClass(cls): |
| 151 |
configureLogging() |
| 152 |
|
| 153 |
################## |
| 154 |
# Utility methods |
| 155 |
################## |
| 156 |
|
| 157 |
def failUnlessAssignRaises(self, exception, obj, prop, value): |
| 158 |
"""Equivalent of :any:`failUnlessRaises`, but used for property assignments instead.""" |
| 159 |
failUnlessAssignRaises(self, exception, obj, prop, value) |
| 160 |
|
| 161 |
############################ |
| 162 |
# Test __repr__ and __str__ |
| 163 |
############################ |
| 164 |
|
| 165 |
def testStringFuncs_001(self): |
| 166 |
""" |
| 167 |
Just make sure that the string functions don't have errors (i.e. bad variable names). |
| 168 |
""" |
| 169 |
obj = BDBRepository() |
| 170 |
obj.__repr__() |
| 171 |
obj.__str__() |
| 172 |
|
| 173 |
################################## |
| 174 |
# Test constructor and attributes |
| 175 |
################################## |
| 176 |
|
| 177 |
def testConstructor_001(self): |
| 178 |
""" |
| 179 |
Test constructor with no values filled in. |
| 180 |
""" |
| 181 |
repository = BDBRepository() |
| 182 |
self.assertEqual("BDB", repository.repositoryType) |
| 183 |
self.assertEqual(None, repository.repositoryPath) |
| 184 |
self.assertEqual(None, repository.collectMode) |
| 185 |
self.assertEqual(None, repository.compressMode) |
| 186 |
|
| 187 |
def testConstructor_002(self): |
| 188 |
""" |
| 189 |
Test constructor with all values filled in. |
| 190 |
""" |
| 191 |
repository = BDBRepository("/path/to/it", "daily", "gzip") |
| 192 |
self.assertEqual("BDB", repository.repositoryType) |
| 193 |
self.assertEqual("/path/to/it", repository.repositoryPath) |
| 194 |
self.assertEqual("daily", repository.collectMode) |
| 195 |
self.assertEqual("gzip", repository.compressMode) |
| 196 |
|
| 197 |
# Removed testConstructor_003 after BDBRepository was deprecated |
| 198 |
|
| 199 |
def testConstructor_004(self): |
| 200 |
""" |
| 201 |
Test assignment of repositoryPath attribute, None value. |
| 202 |
""" |
| 203 |
repository = BDBRepository(repositoryPath="/path/to/something") |
| 204 |
self.assertEqual("/path/to/something", repository.repositoryPath) |
| 205 |
repository.repositoryPath = None |
| 206 |
self.assertEqual(None, repository.repositoryPath) |
| 207 |
|
| 208 |
def testConstructor_005(self): |
| 209 |
""" |
| 210 |
Test assignment of repositoryPath attribute, valid value. |
| 211 |
""" |
| 212 |
repository = BDBRepository() |
| 213 |
self.assertEqual(None, repository.repositoryPath) |
| 214 |
repository.repositoryPath = "/path/to/whatever" |
| 215 |
self.assertEqual("/path/to/whatever", repository.repositoryPath) |
| 216 |
|
| 217 |
def testConstructor_006(self): |
| 218 |
""" |
| 219 |
Test assignment of repositoryPath attribute, invalid value (empty). |
| 220 |
""" |
| 221 |
repository = BDBRepository() |
| 222 |
self.assertEqual(None, repository.repositoryPath) |
| 223 |
self.failUnlessAssignRaises(ValueError, repository, "repositoryPath", "") |
| 224 |
self.assertEqual(None, repository.repositoryPath) |
| 225 |
|
| 226 |
def testConstructor_007(self): |
| 227 |
""" |
| 228 |
Test assignment of repositoryPath attribute, invalid value (not absolute). |
| 229 |
""" |
| 230 |
repository = BDBRepository() |
| 231 |
self.assertEqual(None, repository.repositoryPath) |
| 232 |
self.failUnlessAssignRaises(ValueError, repository, "repositoryPath", "relative/path") |
| 233 |
self.assertEqual(None, repository.repositoryPath) |
| 234 |
|
| 235 |
def testConstructor_008(self): |
| 236 |
""" |
| 237 |
Test assignment of collectMode attribute, None value. |
| 238 |
""" |
| 239 |
repository = BDBRepository(collectMode="daily") |
| 240 |
self.assertEqual("daily", repository.collectMode) |
| 241 |
repository.collectMode = None |
| 242 |
self.assertEqual(None, repository.collectMode) |
| 243 |
|
| 244 |
def testConstructor_009(self): |
| 245 |
""" |
| 246 |
Test assignment of collectMode attribute, valid value. |
| 247 |
""" |
| 248 |
repository = BDBRepository() |
| 249 |
self.assertEqual(None, repository.collectMode) |
| 250 |
repository.collectMode = "daily" |
| 251 |
self.assertEqual("daily", repository.collectMode) |
| 252 |
repository.collectMode = "weekly" |
| 253 |
self.assertEqual("weekly", repository.collectMode) |
| 254 |
repository.collectMode = "incr" |
| 255 |
self.assertEqual("incr", repository.collectMode) |
| 256 |
|
| 257 |
def testConstructor_010(self): |
| 258 |
""" |
| 259 |
Test assignment of collectMode attribute, invalid value (empty). |
| 260 |
""" |
| 261 |
repository = BDBRepository() |
| 262 |
self.assertEqual(None, repository.collectMode) |
| 263 |
self.failUnlessAssignRaises(ValueError, repository, "collectMode", "") |
| 264 |
self.assertEqual(None, repository.collectMode) |
| 265 |
|
| 266 |
def testConstructor_011(self): |
| 267 |
""" |
| 268 |
Test assignment of collectMode attribute, invalid value (not in list). |
| 269 |
""" |
| 270 |
repository = BDBRepository() |
| 271 |
self.assertEqual(None, repository.collectMode) |
| 272 |
self.failUnlessAssignRaises(ValueError, repository, "collectMode", "monthly") |
| 273 |
self.assertEqual(None, repository.collectMode) |
| 274 |
|
| 275 |
def testConstructor_012(self): |
| 276 |
""" |
| 277 |
Test assignment of compressMode attribute, None value. |
| 278 |
""" |
| 279 |
repository = BDBRepository(compressMode="gzip") |
| 280 |
self.assertEqual("gzip", repository.compressMode) |
| 281 |
repository.compressMode = None |
| 282 |
self.assertEqual(None, repository.compressMode) |
| 283 |
|
| 284 |
def testConstructor_013(self): |
| 285 |
""" |
| 286 |
Test assignment of compressMode attribute, valid value. |
| 287 |
""" |
| 288 |
repository = BDBRepository() |
| 289 |
self.assertEqual(None, repository.compressMode) |
| 290 |
repository.compressMode = "none" |
| 291 |
self.assertEqual("none", repository.compressMode) |
| 292 |
repository.compressMode = "bzip2" |
| 293 |
self.assertEqual("bzip2", repository.compressMode) |
| 294 |
repository.compressMode = "gzip" |
| 295 |
self.assertEqual("gzip", repository.compressMode) |
| 296 |
|
| 297 |
def testConstructor_014(self): |
| 298 |
""" |
| 299 |
Test assignment of compressMode attribute, invalid value (empty). |
| 300 |
""" |
| 301 |
repository = BDBRepository() |
| 302 |
self.assertEqual(None, repository.compressMode) |
| 303 |
self.failUnlessAssignRaises(ValueError, repository, "compressMode", "") |
| 304 |
self.assertEqual(None, repository.compressMode) |
| 305 |
|
| 306 |
def testConstructor_015(self): |
| 307 |
""" |
| 308 |
Test assignment of compressMode attribute, invalid value (not in list). |
| 309 |
""" |
| 310 |
repository = BDBRepository() |
| 311 |
self.assertEqual(None, repository.compressMode) |
| 312 |
self.failUnlessAssignRaises(ValueError, repository, "compressMode", "compress") |
| 313 |
self.assertEqual(None, repository.compressMode) |
| 314 |
|
| 315 |
############################ |
| 316 |
# Test comparison operators |
| 317 |
############################ |
| 318 |
|
| 319 |
def testComparison_001(self): |
| 320 |
""" |
| 321 |
Test comparison of two identical objects, all attributes None. |
| 322 |
""" |
| 323 |
repository1 = BDBRepository() |
| 324 |
repository2 = BDBRepository() |
| 325 |
self.assertEqual(repository1, repository2) |
| 326 |
self.assertTrue(repository1 == repository2) |
| 327 |
self.assertTrue(not repository1 < repository2) |
| 328 |
self.assertTrue(repository1 <= repository2) |
| 329 |
self.assertTrue(not repository1 > repository2) |
| 330 |
self.assertTrue(repository1 >= repository2) |
| 331 |
self.assertTrue(not repository1 != repository2) |
| 332 |
|
| 333 |
def testComparison_002(self): |
| 334 |
""" |
| 335 |
Test comparison of two identical objects, all attributes non-None. |
| 336 |
""" |
| 337 |
repository1 = BDBRepository("/path", "daily", "gzip") |
| 338 |
repository2 = BDBRepository("/path", "daily", "gzip") |
| 339 |
self.assertEqual(repository1, repository2) |
| 340 |
self.assertTrue(repository1 == repository2) |
| 341 |
self.assertTrue(not repository1 < repository2) |
| 342 |
self.assertTrue(repository1 <= repository2) |
| 343 |
self.assertTrue(not repository1 > repository2) |
| 344 |
self.assertTrue(repository1 >= repository2) |
| 345 |
self.assertTrue(not repository1 != repository2) |
| 346 |
|
| 347 |
def testComparison_003(self): |
| 348 |
""" |
| 349 |
Test comparison of two differing objects, repositoryPath differs (one None). |
| 350 |
""" |
| 351 |
repository1 = BDBRepository() |
| 352 |
repository2 = BDBRepository(repositoryPath="/zippy") |
| 353 |
self.assertNotEqual(repository1, repository2) |
| 354 |
self.assertTrue(not repository1 == repository2) |
| 355 |
self.assertTrue(repository1 < repository2) |
| 356 |
self.assertTrue(repository1 <= repository2) |
| 357 |
self.assertTrue(not repository1 > repository2) |
| 358 |
self.assertTrue(not repository1 >= repository2) |
| 359 |
self.assertTrue(repository1 != repository2) |
| 360 |
|
| 361 |
def testComparison_004(self): |
| 362 |
""" |
| 363 |
Test comparison of two differing objects, repositoryPath differs. |
| 364 |
""" |
| 365 |
repository1 = BDBRepository("/path", "daily", "gzip") |
| 366 |
repository2 = BDBRepository("/zippy", "daily", "gzip") |
| 367 |
self.assertNotEqual(repository1, repository2) |
| 368 |
self.assertTrue(not repository1 == repository2) |
| 369 |
self.assertTrue(repository1 < repository2) |
| 370 |
self.assertTrue(repository1 <= repository2) |
| 371 |
self.assertTrue(not repository1 > repository2) |
| 372 |
self.assertTrue(not repository1 >= repository2) |
| 373 |
self.assertTrue(repository1 != repository2) |
| 374 |
|
| 375 |
def testComparison_005(self): |
| 376 |
""" |
| 377 |
Test comparison of two differing objects, collectMode differs (one None). |
| 378 |
""" |
| 379 |
repository1 = BDBRepository() |
| 380 |
repository2 = BDBRepository(collectMode="incr") |
| 381 |
self.assertNotEqual(repository1, repository2) |
| 382 |
self.assertTrue(not repository1 == repository2) |
| 383 |
self.assertTrue(repository1 < repository2) |
| 384 |
self.assertTrue(repository1 <= repository2) |
| 385 |
self.assertTrue(not repository1 > repository2) |
| 386 |
self.assertTrue(not repository1 >= repository2) |
| 387 |
self.assertTrue(repository1 != repository2) |
| 388 |
|
| 389 |
def testComparison_006(self): |
| 390 |
""" |
| 391 |
Test comparison of two differing objects, collectMode differs. |
| 392 |
""" |
| 393 |
repository1 = BDBRepository("/path", "daily", "gzip") |
| 394 |
repository2 = BDBRepository("/path", "incr", "gzip") |
| 395 |
self.assertNotEqual(repository1, repository2) |
| 396 |
self.assertTrue(not repository1 == repository2) |
| 397 |
self.assertTrue(repository1 < repository2) |
| 398 |
self.assertTrue(repository1 <= repository2) |
| 399 |
self.assertTrue(not repository1 > repository2) |
| 400 |
self.assertTrue(not repository1 >= repository2) |
| 401 |
self.assertTrue(repository1 != repository2) |
| 402 |
|
| 403 |
def testComparison_007(self): |
| 404 |
""" |
| 405 |
Test comparison of two differing objects, compressMode differs (one None). |
| 406 |
""" |
| 407 |
repository1 = BDBRepository() |
| 408 |
repository2 = BDBRepository(compressMode="gzip") |
| 409 |
self.assertNotEqual(repository1, repository2) |
| 410 |
self.assertTrue(not repository1 == repository2) |
| 411 |
self.assertTrue(repository1 < repository2) |
| 412 |
self.assertTrue(repository1 <= repository2) |
| 413 |
self.assertTrue(not repository1 > repository2) |
| 414 |
self.assertTrue(not repository1 >= repository2) |
| 415 |
self.assertTrue(repository1 != repository2) |
| 416 |
|
| 417 |
def testComparison_008(self): |
| 418 |
""" |
| 419 |
Test comparison of two differing objects, compressMode differs. |
| 420 |
""" |
| 421 |
repository1 = BDBRepository("/path", "daily", "bzip2") |
| 422 |
repository2 = BDBRepository("/path", "daily", "gzip") |
| 423 |
self.assertNotEqual(repository1, repository2) |
| 424 |
self.assertTrue(not repository1 == repository2) |
| 425 |
self.assertTrue(repository1 < repository2) |
| 426 |
self.assertTrue(repository1 <= repository2) |
| 427 |
self.assertTrue(not repository1 > repository2) |
| 428 |
self.assertTrue(not repository1 >= repository2) |
| 429 |
self.assertTrue(repository1 != repository2) |
| 430 |
|
| 431 |
|
| 432 |
########################### |
| 433 |
# TestFSFSRepository class |
| 434 |
########################### |
| 435 |
|
| 436 |
|
| 437 |
class TestFSFSRepository(unittest.TestCase): |
| 438 |
""" |
| 439 |
Tests for the FSFSRepository class. |
| 440 |
|
| 441 |
*Note:* This class is deprecated. These tests are kept around to make sure |
| 442 |
that we don't accidentally break the interface. |
| 443 |
""" |
| 444 |
|
| 445 |
################ |
| 446 |
# Setup methods |
| 447 |
################ |
| 448 |
|
| 449 |
@classmethod |
| 450 |
def setUpClass(cls): |
| 451 |
configureLogging() |
| 452 |
|
| 453 |
################## |
| 454 |
# Utility methods |
| 455 |
################## |
| 456 |
|
| 457 |
def failUnlessAssignRaises(self, exception, obj, prop, value): |
| 458 |
"""Equivalent of :any:`failUnlessRaises`, but used for property assignments instead.""" |
| 459 |
failUnlessAssignRaises(self, exception, obj, prop, value) |
| 460 |
|
| 461 |
############################ |
| 462 |
# Test __repr__ and __str__ |
| 463 |
############################ |
| 464 |
|
| 465 |
def testStringFuncs_001(self): |
| 466 |
""" |
| 467 |
Just make sure that the string functions don't have errors (i.e. bad variable names). |
| 468 |
""" |
| 469 |
obj = FSFSRepository() |
| 470 |
obj.__repr__() |
| 471 |
obj.__str__() |
| 472 |
|
| 473 |
################################## |
| 474 |
# Test constructor and attributes |
| 475 |
################################## |
| 476 |
|
| 477 |
def testConstructor_001(self): |
| 478 |
""" |
| 479 |
Test constructor with no values filled in. |
| 480 |
""" |
| 481 |
repository = FSFSRepository() |
| 482 |
self.assertEqual("FSFS", repository.repositoryType) |
| 483 |
self.assertEqual(None, repository.repositoryPath) |
| 484 |
self.assertEqual(None, repository.collectMode) |
| 485 |
self.assertEqual(None, repository.compressMode) |
| 486 |
|
| 487 |
def testConstructor_002(self): |
| 488 |
""" |
| 489 |
Test constructor with all values filled in. |
| 490 |
""" |
| 491 |
repository = FSFSRepository("/path/to/it", "daily", "gzip") |
| 492 |
self.assertEqual("FSFS", repository.repositoryType) |
| 493 |
self.assertEqual("/path/to/it", repository.repositoryPath) |
| 494 |
self.assertEqual("daily", repository.collectMode) |
| 495 |
self.assertEqual("gzip", repository.compressMode) |
| 496 |
|
| 497 |
# Removed testConstructor_003 after FSFSRepository was deprecated |
| 498 |
|
| 499 |
def testConstructor_004(self): |
| 500 |
""" |
| 501 |
Test assignment of repositoryPath attribute, None value. |
| 502 |
""" |
| 503 |
repository = FSFSRepository(repositoryPath="/path/to/something") |
| 504 |
self.assertEqual("/path/to/something", repository.repositoryPath) |
| 505 |
repository.repositoryPath = None |
| 506 |
self.assertEqual(None, repository.repositoryPath) |
| 507 |
|
| 508 |
def testConstructor_005(self): |
| 509 |
""" |
| 510 |
Test assignment of repositoryPath attribute, valid value. |
| 511 |
""" |
| 512 |
repository = FSFSRepository() |
| 513 |
self.assertEqual(None, repository.repositoryPath) |
| 514 |
repository.repositoryPath = "/path/to/whatever" |
| 515 |
self.assertEqual("/path/to/whatever", repository.repositoryPath) |
| 516 |
|
| 517 |
def testConstructor_006(self): |
| 518 |
""" |
| 519 |
Test assignment of repositoryPath attribute, invalid value (empty). |
| 520 |
""" |
| 521 |
repository = FSFSRepository() |
| 522 |
self.assertEqual(None, repository.repositoryPath) |
| 523 |
self.failUnlessAssignRaises(ValueError, repository, "repositoryPath", "") |
| 524 |
self.assertEqual(None, repository.repositoryPath) |
| 525 |
|
| 526 |
def testConstructor_007(self): |
| 527 |
""" |
| 528 |
Test assignment of repositoryPath attribute, invalid value (not absolute). |
| 529 |
""" |
| 530 |
repository = FSFSRepository() |
| 531 |
self.assertEqual(None, repository.repositoryPath) |
| 532 |
self.failUnlessAssignRaises(ValueError, repository, "repositoryPath", "relative/path") |
| 533 |
self.assertEqual(None, repository.repositoryPath) |
| 534 |
|
| 535 |
def testConstructor_008(self): |
| 536 |
""" |
| 537 |
Test assignment of collectMode attribute, None value. |
| 538 |
""" |
| 539 |
repository = FSFSRepository(collectMode="daily") |
| 540 |
self.assertEqual("daily", repository.collectMode) |
| 541 |
repository.collectMode = None |
| 542 |
self.assertEqual(None, repository.collectMode) |
| 543 |
|
| 544 |
def testConstructor_009(self): |
| 545 |
""" |
| 546 |
Test assignment of collectMode attribute, valid value. |
| 547 |
""" |
| 548 |
repository = FSFSRepository() |
| 549 |
self.assertEqual(None, repository.collectMode) |
| 550 |
repository.collectMode = "daily" |
| 551 |
self.assertEqual("daily", repository.collectMode) |
| 552 |
repository.collectMode = "weekly" |
| 553 |
self.assertEqual("weekly", repository.collectMode) |
| 554 |
repository.collectMode = "incr" |
| 555 |
self.assertEqual("incr", repository.collectMode) |
| 556 |
|
| 557 |
def testConstructor_010(self): |
| 558 |
""" |
| 559 |
Test assignment of collectMode attribute, invalid value (empty). |
| 560 |
""" |
| 561 |
repository = FSFSRepository() |
| 562 |
self.assertEqual(None, repository.collectMode) |
| 563 |
self.failUnlessAssignRaises(ValueError, repository, "collectMode", "") |
| 564 |
self.assertEqual(None, repository.collectMode) |
| 565 |
|
| 566 |
def testConstructor_011(self): |
| 567 |
""" |
| 568 |
Test assignment of collectMode attribute, invalid value (not in list). |
| 569 |
""" |
| 570 |
repository = FSFSRepository() |
| 571 |
self.assertEqual(None, repository.collectMode) |
| 572 |
self.failUnlessAssignRaises(ValueError, repository, "collectMode", "monthly") |
| 573 |
self.assertEqual(None, repository.collectMode) |
| 574 |
|
| 575 |
def testConstructor_012(self): |
| 576 |
""" |
| 577 |
Test assignment of compressMode attribute, None value. |
| 578 |
""" |
| 579 |
repository = FSFSRepository(compressMode="gzip") |
| 580 |
self.assertEqual("gzip", repository.compressMode) |
| 581 |
repository.compressMode = None |
| 582 |
self.assertEqual(None, repository.compressMode) |
| 583 |
|
| 584 |
def testConstructor_013(self): |
| 585 |
""" |
| 586 |
Test assignment of compressMode attribute, valid value. |
| 587 |
""" |
| 588 |
repository = FSFSRepository() |
| 589 |
self.assertEqual(None, repository.compressMode) |
| 590 |
repository.compressMode = "none" |
| 591 |
self.assertEqual("none", repository.compressMode) |
| 592 |
repository.compressMode = "bzip2" |
| 593 |
self.assertEqual("bzip2", repository.compressMode) |
| 594 |
repository.compressMode = "gzip" |
| 595 |
self.assertEqual("gzip", repository.compressMode) |
| 596 |
|
| 597 |
def testConstructor_014(self): |
| 598 |
""" |
| 599 |
Test assignment of compressMode attribute, invalid value (empty). |
| 600 |
""" |
| 601 |
repository = FSFSRepository() |
| 602 |
self.assertEqual(None, repository.compressMode) |
| 603 |
self.failUnlessAssignRaises(ValueError, repository, "compressMode", "") |
| 604 |
self.assertEqual(None, repository.compressMode) |
| 605 |
|
| 606 |
def testConstructor_015(self): |
| 607 |
""" |
| 608 |
Test assignment of compressMode attribute, invalid value (not in list). |
| 609 |
""" |
| 610 |
repository = FSFSRepository() |
| 611 |
self.assertEqual(None, repository.compressMode) |
| 612 |
self.failUnlessAssignRaises(ValueError, repository, "compressMode", "compress") |
| 613 |
self.assertEqual(None, repository.compressMode) |
| 614 |
|
| 615 |
############################ |
| 616 |
# Test comparison operators |
| 617 |
############################ |
| 618 |
|
| 619 |
def testComparison_001(self): |
| 620 |
""" |
| 621 |
Test comparison of two identical objects, all attributes None. |
| 622 |
""" |
| 623 |
repository1 = FSFSRepository() |
| 624 |
repository2 = FSFSRepository() |
| 625 |
self.assertEqual(repository1, repository2) |
| 626 |
self.assertTrue(repository1 == repository2) |
| 627 |
self.assertTrue(not repository1 < repository2) |
| 628 |
self.assertTrue(repository1 <= repository2) |
| 629 |
self.assertTrue(not repository1 > repository2) |
| 630 |
self.assertTrue(repository1 >= repository2) |
| 631 |
self.assertTrue(not repository1 != repository2) |
| 632 |
|
| 633 |
def testComparison_002(self): |
| 634 |
""" |
| 635 |
Test comparison of two identical objects, all attributes non-None. |
| 636 |
""" |
| 637 |
repository1 = FSFSRepository("/path", "daily", "gzip") |
| 638 |
repository2 = FSFSRepository("/path", "daily", "gzip") |
| 639 |
self.assertEqual(repository1, repository2) |
| 640 |
self.assertTrue(repository1 == repository2) |
| 641 |
self.assertTrue(not repository1 < repository2) |
| 642 |
self.assertTrue(repository1 <= repository2) |
| 643 |
self.assertTrue(not repository1 > repository2) |
| 644 |
self.assertTrue(repository1 >= repository2) |
| 645 |
self.assertTrue(not repository1 != repository2) |
| 646 |
|
| 647 |
def testComparison_003(self): |
| 648 |
""" |
| 649 |
Test comparison of two differing objects, repositoryPath differs (one None). |
| 650 |
""" |
| 651 |
repository1 = FSFSRepository() |
| 652 |
repository2 = FSFSRepository(repositoryPath="/zippy") |
| 653 |
self.assertNotEqual(repository1, repository2) |
| 654 |
self.assertTrue(not repository1 == repository2) |
| 655 |
self.assertTrue(repository1 < repository2) |
| 656 |
self.assertTrue(repository1 <= repository2) |
| 657 |
self.assertTrue(not repository1 > repository2) |
| 658 |
self.assertTrue(not repository1 >= repository2) |
| 659 |
self.assertTrue(repository1 != repository2) |
| 660 |
|
| 661 |
def testComparison_004(self): |
| 662 |
""" |
| 663 |
Test comparison of two differing objects, repositoryPath differs. |
| 664 |
""" |
| 665 |
repository1 = FSFSRepository("/path", "daily", "gzip") |
| 666 |
repository2 = FSFSRepository("/zippy", "daily", "gzip") |
| 667 |
self.assertNotEqual(repository1, repository2) |
| 668 |
self.assertTrue(not repository1 == repository2) |
| 669 |
self.assertTrue(repository1 < repository2) |
| 670 |
self.assertTrue(repository1 <= repository2) |
| 671 |
self.assertTrue(not repository1 > repository2) |
| 672 |
self.assertTrue(not repository1 >= repository2) |
| 673 |
self.assertTrue(repository1 != repository2) |
| 674 |
|
| 675 |
def testComparison_005(self): |
| 676 |
""" |
| 677 |
Test comparison of two differing objects, collectMode differs (one None). |
| 678 |
""" |
| 679 |
repository1 = FSFSRepository() |
| 680 |
repository2 = FSFSRepository(collectMode="incr") |
| 681 |
self.assertNotEqual(repository1, repository2) |
| 682 |
self.assertTrue(not repository1 == repository2) |
| 683 |
self.assertTrue(repository1 < repository2) |
| 684 |
self.assertTrue(repository1 <= repository2) |
| 685 |
self.assertTrue(not repository1 > repository2) |
| 686 |
self.assertTrue(not repository1 >= repository2) |
| 687 |
self.assertTrue(repository1 != repository2) |
| 688 |
|
| 689 |
def testComparison_006(self): |
| 690 |
""" |
| 691 |
Test comparison of two differing objects, collectMode differs. |
| 692 |
""" |
| 693 |
repository1 = FSFSRepository("/path", "daily", "gzip") |
| 694 |
repository2 = FSFSRepository("/path", "incr", "gzip") |
| 695 |
self.assertNotEqual(repository1, repository2) |
| 696 |
self.assertTrue(not repository1 == repository2) |
| 697 |
self.assertTrue(repository1 < repository2) |
| 698 |
self.assertTrue(repository1 <= repository2) |
| 699 |
self.assertTrue(not repository1 > repository2) |
| 700 |
self.assertTrue(not repository1 >= repository2) |
| 701 |
self.assertTrue(repository1 != repository2) |
| 702 |
|
| 703 |
def testComparison_007(self): |
| 704 |
""" |
| 705 |
Test comparison of two differing objects, compressMode differs (one None). |
| 706 |
""" |
| 707 |
repository1 = FSFSRepository() |
| 708 |
repository2 = FSFSRepository(compressMode="gzip") |
| 709 |
self.assertNotEqual(repository1, repository2) |
| 710 |
self.assertTrue(not repository1 == repository2) |
| 711 |
self.assertTrue(repository1 < repository2) |
| 712 |
self.assertTrue(repository1 <= repository2) |
| 713 |
self.assertTrue(not repository1 > repository2) |
| 714 |
self.assertTrue(not repository1 >= repository2) |
| 715 |
self.assertTrue(repository1 != repository2) |
| 716 |
|
| 717 |
def testComparison_008(self): |
| 718 |
""" |
| 719 |
Test comparison of two differing objects, compressMode differs. |
| 720 |
""" |
| 721 |
repository1 = FSFSRepository("/path", "daily", "bzip2") |
| 722 |
repository2 = FSFSRepository("/path", "daily", "gzip") |
| 723 |
self.assertNotEqual(repository1, repository2) |
| 724 |
self.assertTrue(not repository1 == repository2) |
| 725 |
self.assertTrue(repository1 < repository2) |
| 726 |
self.assertTrue(repository1 <= repository2) |
| 727 |
self.assertTrue(not repository1 > repository2) |
| 728 |
self.assertTrue(not repository1 >= repository2) |
| 729 |
self.assertTrue(repository1 != repository2) |
| 730 |
|
| 731 |
|
| 732 |
####################### |
| 733 |
# TestRepository class |
| 734 |
####################### |
| 735 |
|
| 736 |
|
| 737 |
class TestRepository(unittest.TestCase): |
| 738 |
"""Tests for the Repository class.""" |
| 739 |
|
| 740 |
################ |
| 741 |
# Setup methods |
| 742 |
################ |
| 743 |
|
| 744 |
@classmethod |
| 745 |
def setUpClass(cls): |
| 746 |
configureLogging() |
| 747 |
|
| 748 |
################## |
| 749 |
# Utility methods |
| 750 |
################## |
| 751 |
|
| 752 |
def failUnlessAssignRaises(self, exception, obj, prop, value): |
| 753 |
"""Equivalent of :any:`failUnlessRaises`, but used for property assignments instead.""" |
| 754 |
failUnlessAssignRaises(self, exception, obj, prop, value) |
| 755 |
|
| 756 |
############################ |
| 757 |
# Test __repr__ and __str__ |
| 758 |
############################ |
| 759 |
|
| 760 |
def testStringFuncs_001(self): |
| 761 |
""" |
| 762 |
Just make sure that the string functions don't have errors (i.e. bad variable names). |
| 763 |
""" |
| 764 |
obj = Repository() |
| 765 |
obj.__repr__() |
| 766 |
obj.__str__() |
| 767 |
|
| 768 |
################################## |
| 769 |
# Test constructor and attributes |
| 770 |
################################## |
| 771 |
|
| 772 |
def testConstructor_001(self): |
| 773 |
""" |
| 774 |
Test constructor with no values filled in. |
| 775 |
""" |
| 776 |
repository = Repository() |
| 777 |
self.assertEqual(None, repository.repositoryType) |
| 778 |
self.assertEqual(None, repository.repositoryPath) |
| 779 |
self.assertEqual(None, repository.collectMode) |
| 780 |
self.assertEqual(None, repository.compressMode) |
| 781 |
|
| 782 |
def testConstructor_002(self): |
| 783 |
""" |
| 784 |
Test constructor with all values filled in. |
| 785 |
""" |
| 786 |
repository = Repository("type", "/path/to/it", "daily", "gzip") |
| 787 |
self.assertEqual("type", repository.repositoryType) |
| 788 |
self.assertEqual("/path/to/it", repository.repositoryPath) |
| 789 |
self.assertEqual("daily", repository.collectMode) |
| 790 |
self.assertEqual("gzip", repository.compressMode) |
| 791 |
|
| 792 |
def testConstructor_003(self): |
| 793 |
""" |
| 794 |
Test assignment of repositoryType attribute, None value. |
| 795 |
""" |
| 796 |
repository = Repository(repositoryType="type") |
| 797 |
self.assertEqual("type", repository.repositoryType) |
| 798 |
repository.repositoryType = None |
| 799 |
self.assertEqual(None, repository.repositoryType) |
| 800 |
|
| 801 |
def testConstructor_004(self): |
| 802 |
""" |
| 803 |
Test assignment of repositoryType attribute, non-None value. |
| 804 |
""" |
| 805 |
repository = Repository() |
| 806 |
self.assertEqual(None, repository.repositoryType) |
| 807 |
repository.repositoryType = "" |
| 808 |
self.assertEqual("", repository.repositoryType) |
| 809 |
repository.repositoryType = "test" |
| 810 |
self.assertEqual("test", repository.repositoryType) |
| 811 |
|
| 812 |
def testConstructor_005(self): |
| 813 |
""" |
| 814 |
Test assignment of repositoryPath attribute, None value. |
| 815 |
""" |
| 816 |
repository = Repository(repositoryPath="/path/to/something") |
| 817 |
self.assertEqual("/path/to/something", repository.repositoryPath) |
| 818 |
repository.repositoryPath = None |
| 819 |
self.assertEqual(None, repository.repositoryPath) |
| 820 |
|
| 821 |
def testConstructor_006(self): |
| 822 |
""" |
| 823 |
Test assignment of repositoryPath attribute, valid value. |
| 824 |
""" |
| 825 |
repository = Repository() |
| 826 |
self.assertEqual(None, repository.repositoryPath) |
| 827 |
repository.repositoryPath = "/path/to/whatever" |
| 828 |
self.assertEqual("/path/to/whatever", repository.repositoryPath) |
| 829 |
|
| 830 |
def testConstructor_007(self): |
| 831 |
""" |
| 832 |
Test assignment of repositoryPath attribute, invalid value (empty). |
| 833 |
""" |
| 834 |
repository = Repository() |
| 835 |
self.assertEqual(None, repository.repositoryPath) |
| 836 |
self.failUnlessAssignRaises(ValueError, repository, "repositoryPath", "") |
| 837 |
self.assertEqual(None, repository.repositoryPath) |
| 838 |
|
| 839 |
def testConstructor_008(self): |
| 840 |
""" |
| 841 |
Test assignment of repositoryPath attribute, invalid value (not absolute). |
| 842 |
""" |
| 843 |
repository = Repository() |
| 844 |
self.assertEqual(None, repository.repositoryPath) |
| 845 |
self.failUnlessAssignRaises(ValueError, repository, "repositoryPath", "relative/path") |
| 846 |
self.assertEqual(None, repository.repositoryPath) |
| 847 |
|
| 848 |
def testConstructor_009(self): |
| 849 |
""" |
| 850 |
Test assignment of collectMode attribute, None value. |
| 851 |
""" |
| 852 |
repository = Repository(collectMode="daily") |
| 853 |
self.assertEqual("daily", repository.collectMode) |
| 854 |
repository.collectMode = None |
| 855 |
self.assertEqual(None, repository.collectMode) |
| 856 |
|
| 857 |
def testConstructor_010(self): |
| 858 |
""" |
| 859 |
Test assignment of collectMode attribute, valid value. |
| 860 |
""" |
| 861 |
repository = Repository() |
| 862 |
self.assertEqual(None, repository.collectMode) |
| 863 |
repository.collectMode = "daily" |
| 864 |
self.assertEqual("daily", repository.collectMode) |
| 865 |
repository.collectMode = "weekly" |
| 866 |
self.assertEqual("weekly", repository.collectMode) |
| 867 |
repository.collectMode = "incr" |
| 868 |
self.assertEqual("incr", repository.collectMode) |
| 869 |
|
| 870 |
def testConstructor_011(self): |
| 871 |
""" |
| 872 |
Test assignment of collectMode attribute, invalid value (empty). |
| 873 |
""" |
| 874 |
repository = Repository() |
| 875 |
self.assertEqual(None, repository.collectMode) |
| 876 |
self.failUnlessAssignRaises(ValueError, repository, "collectMode", "") |
| 877 |
self.assertEqual(None, repository.collectMode) |
| 878 |
|
| 879 |
def testConstructor_012(self): |
| 880 |
""" |
| 881 |
Test assignment of collectMode attribute, invalid value (not in list). |
| 882 |
""" |
| 883 |
repository = Repository() |
| 884 |
self.assertEqual(None, repository.collectMode) |
| 885 |
self.failUnlessAssignRaises(ValueError, repository, "collectMode", "monthly") |
| 886 |
self.assertEqual(None, repository.collectMode) |
| 887 |
|
| 888 |
def testConstructor_013(self): |
| 889 |
""" |
| 890 |
Test assignment of compressMode attribute, None value. |
| 891 |
""" |
| 892 |
repository = Repository(compressMode="gzip") |
| 893 |
self.assertEqual("gzip", repository.compressMode) |
| 894 |
repository.compressMode = None |
| 895 |
self.assertEqual(None, repository.compressMode) |
| 896 |
|
| 897 |
def testConstructor_014(self): |
| 898 |
""" |
| 899 |
Test assignment of compressMode attribute, valid value. |
| 900 |
""" |
| 901 |
repository = Repository() |
| 902 |
self.assertEqual(None, repository.compressMode) |
| 903 |
repository.compressMode = "none" |
| 904 |
self.assertEqual("none", repository.compressMode) |
| 905 |
repository.compressMode = "bzip2" |
| 906 |
self.assertEqual("bzip2", repository.compressMode) |
| 907 |
repository.compressMode = "gzip" |
| 908 |
self.assertEqual("gzip", repository.compressMode) |
| 909 |
|
| 910 |
def testConstructor_015(self): |
| 911 |
""" |
| 912 |
Test assignment of compressMode attribute, invalid value (empty). |
| 913 |
""" |
| 914 |
repository = Repository() |
| 915 |
self.assertEqual(None, repository.compressMode) |
| 916 |
self.failUnlessAssignRaises(ValueError, repository, "compressMode", "") |
| 917 |
self.assertEqual(None, repository.compressMode) |
| 918 |
|
| 919 |
def testConstructor_016(self): |
| 920 |
""" |
| 921 |
Test assignment of compressMode attribute, invalid value (not in list). |
| 922 |
""" |
| 923 |
repository = Repository() |
| 924 |
self.assertEqual(None, repository.compressMode) |
| 925 |
self.failUnlessAssignRaises(ValueError, repository, "compressMode", "compress") |
| 926 |
self.assertEqual(None, repository.compressMode) |
| 927 |
|
| 928 |
############################ |
| 929 |
# Test comparison operators |
| 930 |
############################ |
| 931 |
|
| 932 |
def testComparison_001(self): |
| 933 |
""" |
| 934 |
Test comparison of two identical objects, all attributes None. |
| 935 |
""" |
| 936 |
repository1 = Repository() |
| 937 |
repository2 = Repository() |
| 938 |
self.assertEqual(repository1, repository2) |
| 939 |
self.assertTrue(repository1 == repository2) |
| 940 |
self.assertTrue(not repository1 < repository2) |
| 941 |
self.assertTrue(repository1 <= repository2) |
| 942 |
self.assertTrue(not repository1 > repository2) |
| 943 |
self.assertTrue(repository1 >= repository2) |
| 944 |
self.assertTrue(not repository1 != repository2) |
| 945 |
|
| 946 |
def testComparison_002(self): |
| 947 |
""" |
| 948 |
Test comparison of two identical objects, all attributes non-None. |
| 949 |
""" |
| 950 |
repository1 = Repository("type", "/path", "daily", "gzip") |
| 951 |
repository2 = Repository("type", "/path", "daily", "gzip") |
| 952 |
self.assertEqual(repository1, repository2) |
| 953 |
self.assertTrue(repository1 == repository2) |
| 954 |
self.assertTrue(not repository1 < repository2) |
| 955 |
self.assertTrue(repository1 <= repository2) |
| 956 |
self.assertTrue(not repository1 > repository2) |
| 957 |
self.assertTrue(repository1 >= repository2) |
| 958 |
self.assertTrue(not repository1 != repository2) |
| 959 |
|
| 960 |
def testComparison_003(self): |
| 961 |
""" |
| 962 |
Test comparison of two differing objects, repositoryType differs (one None). |
| 963 |
""" |
| 964 |
repository1 = Repository() |
| 965 |
repository2 = Repository(repositoryType="type") |
| 966 |
self.assertNotEqual(repository1, repository2) |
| 967 |
self.assertTrue(not repository1 == repository2) |
| 968 |
self.assertTrue(repository1 < repository2) |
| 969 |
self.assertTrue(repository1 <= repository2) |
| 970 |
self.assertTrue(not repository1 > repository2) |
| 971 |
self.assertTrue(not repository1 >= repository2) |
| 972 |
self.assertTrue(repository1 != repository2) |
| 973 |
|
| 974 |
def testComparison_004(self): |
| 975 |
""" |
| 976 |
Test comparison of two differing objects, repositoryType differs. |
| 977 |
""" |
| 978 |
repository1 = Repository("other", "/path", "daily", "gzip") |
| 979 |
repository2 = Repository("type", "/path", "daily", "gzip") |
| 980 |
self.assertNotEqual(repository1, repository2) |
| 981 |
self.assertTrue(not repository1 == repository2) |
| 982 |
self.assertTrue(repository1 < repository2) |
| 983 |
self.assertTrue(repository1 <= repository2) |
| 984 |
self.assertTrue(not repository1 > repository2) |
| 985 |
self.assertTrue(not repository1 >= repository2) |
| 986 |
self.assertTrue(repository1 != repository2) |
| 987 |
|
| 988 |
def testComparison_004a(self): |
| 989 |
""" |
| 990 |
Test comparison of two differing objects, repositoryPath differs (one None). |
| 991 |
""" |
| 992 |
repository1 = Repository() |
| 993 |
repository2 = Repository(repositoryPath="/zippy") |
| 994 |
self.assertNotEqual(repository1, repository2) |
| 995 |
self.assertTrue(not repository1 == repository2) |
| 996 |
self.assertTrue(repository1 < repository2) |
| 997 |
self.assertTrue(repository1 <= repository2) |
| 998 |
self.assertTrue(not repository1 > repository2) |
| 999 |
self.assertTrue(not repository1 >= repository2) |
| 1000 |
self.assertTrue(repository1 != repository2) |
| 1001 |
|
| 1002 |
def testComparison_005(self): |
| 1003 |
""" |
| 1004 |
Test comparison of two differing objects, repositoryPath differs. |
| 1005 |
""" |
| 1006 |
repository1 = Repository("type", "/path", "daily", "gzip") |
| 1007 |
repository2 = Repository("type", "/zippy", "daily", "gzip") |
| 1008 |
self.assertNotEqual(repository1, repository2) |
| 1009 |
self.assertTrue(not repository1 == repository2) |
| 1010 |
self.assertTrue(repository1 < repository2) |
| 1011 |
self.assertTrue(repository1 <= repository2) |
| 1012 |
self.assertTrue(not repository1 > repository2) |
| 1013 |
self.assertTrue(not repository1 >= repository2) |
| 1014 |
self.assertTrue(repository1 != repository2) |
| 1015 |
|
| 1016 |
def testComparison_006(self): |
| 1017 |
""" |
| 1018 |
Test comparison of two differing objects, collectMode differs (one None). |
| 1019 |
""" |
| 1020 |
repository1 = Repository() |
| 1021 |
repository2 = Repository(collectMode="incr") |
| 1022 |
self.assertNotEqual(repository1, repository2) |
| 1023 |
self.assertTrue(not repository1 == repository2) |
| 1024 |
self.assertTrue(repository1 < repository2) |
| 1025 |
self.assertTrue(repository1 <= repository2) |
| 1026 |
self.assertTrue(not repository1 > repository2) |
| 1027 |
self.assertTrue(not repository1 >= repository2) |
| 1028 |
self.assertTrue(repository1 != repository2) |
| 1029 |
|
| 1030 |
def testComparison_007(self): |
| 1031 |
""" |
| 1032 |
Test comparison of two differing objects, collectMode differs. |
| 1033 |
""" |
| 1034 |
repository1 = Repository("type", "/path", "daily", "gzip") |
| 1035 |
repository2 = Repository("type", "/path", "incr", "gzip") |
| 1036 |
self.assertNotEqual(repository1, repository2) |
| 1037 |
self.assertTrue(not repository1 == repository2) |
| 1038 |
self.assertTrue(repository1 < repository2) |
| 1039 |
self.assertTrue(repository1 <= repository2) |
| 1040 |
self.assertTrue(not repository1 > repository2) |
| 1041 |
self.assertTrue(not repository1 >= repository2) |
| 1042 |
self.assertTrue(repository1 != repository2) |
| 1043 |
|
| 1044 |
def testComparison_008(self): |
| 1045 |
""" |
| 1046 |
Test comparison of two differing objects, compressMode differs (one None). |
| 1047 |
""" |
| 1048 |
repository1 = Repository() |
| 1049 |
repository2 = Repository(compressMode="gzip") |
| 1050 |
self.assertNotEqual(repository1, repository2) |
| 1051 |
self.assertTrue(not repository1 == repository2) |
| 1052 |
self.assertTrue(repository1 < repository2) |
| 1053 |
self.assertTrue(repository1 <= repository2) |
| 1054 |
self.assertTrue(not repository1 > repository2) |
| 1055 |
self.assertTrue(not repository1 >= repository2) |
| 1056 |
self.assertTrue(repository1 != repository2) |
| 1057 |
|
| 1058 |
def testComparison_009(self): |
| 1059 |
""" |
| 1060 |
Test comparison of two differing objects, compressMode differs. |
| 1061 |
""" |
| 1062 |
repository1 = Repository("type", "/path", "daily", "bzip2") |
| 1063 |
repository2 = Repository("type", "/path", "daily", "gzip") |
| 1064 |
self.assertNotEqual(repository1, repository2) |
| 1065 |
self.assertTrue(not repository1 == repository2) |
| 1066 |
self.assertTrue(repository1 < repository2) |
| 1067 |
self.assertTrue(repository1 <= repository2) |
| 1068 |
self.assertTrue(not repository1 > repository2) |
| 1069 |
self.assertTrue(not repository1 >= repository2) |
| 1070 |
self.assertTrue(repository1 != repository2) |
| 1071 |
|
| 1072 |
|
| 1073 |
########################## |
| 1074 |
# TestRepositoryDir class |
| 1075 |
########################## |
| 1076 |
|
| 1077 |
|
| 1078 |
class TestRepositoryDir(unittest.TestCase): |
| 1079 |
"""Tests for the RepositoryDir class.""" |
| 1080 |
|
| 1081 |
################ |
| 1082 |
# Setup methods |
| 1083 |
################ |
| 1084 |
|
| 1085 |
@classmethod |
| 1086 |
def setUpClass(cls): |
| 1087 |
configureLogging() |
| 1088 |
|
| 1089 |
################## |
| 1090 |
# Utility methods |
| 1091 |
################## |
| 1092 |
|
| 1093 |
def failUnlessAssignRaises(self, exception, obj, prop, value): |
| 1094 |
"""Equivalent of :any:`failUnlessRaises`, but used for property assignments instead.""" |
| 1095 |
failUnlessAssignRaises(self, exception, obj, prop, value) |
| 1096 |
|
| 1097 |
############################ |
| 1098 |
# Test __repr__ and __str__ |
| 1099 |
############################ |
| 1100 |
|
| 1101 |
def testStringFuncs_001(self): |
| 1102 |
""" |
| 1103 |
Just make sure that the string functions don't have errors (i.e. bad variable names). |
| 1104 |
""" |
| 1105 |
obj = RepositoryDir() |
| 1106 |
obj.__repr__() |
| 1107 |
obj.__str__() |
| 1108 |
|
| 1109 |
################################## |
| 1110 |
# Test constructor and attributes |
| 1111 |
################################## |
| 1112 |
|
| 1113 |
def testConstructor_001(self): |
| 1114 |
""" |
| 1115 |
Test constructor with no values filled in. |
| 1116 |
""" |
| 1117 |
repositoryDir = RepositoryDir() |
| 1118 |
self.assertEqual(None, repositoryDir.repositoryType) |
| 1119 |
self.assertEqual(None, repositoryDir.directoryPath) |
| 1120 |
self.assertEqual(None, repositoryDir.collectMode) |
| 1121 |
self.assertEqual(None, repositoryDir.compressMode) |
| 1122 |
self.assertEqual(None, repositoryDir.relativeExcludePaths) |
| 1123 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1124 |
|
| 1125 |
def testConstructor_002(self): |
| 1126 |
""" |
| 1127 |
Test constructor with all values filled in. |
| 1128 |
""" |
| 1129 |
repositoryDir = RepositoryDir("type", "/path/to/it", "daily", "gzip", ["whatever"], [".*software.*"]) |
| 1130 |
self.assertEqual("type", repositoryDir.repositoryType) |
| 1131 |
self.assertEqual("/path/to/it", repositoryDir.directoryPath) |
| 1132 |
self.assertEqual("daily", repositoryDir.collectMode) |
| 1133 |
self.assertEqual("gzip", repositoryDir.compressMode) |
| 1134 |
self.assertEqual(["whatever"], repositoryDir.relativeExcludePaths) |
| 1135 |
self.assertEqual([".*software.*"], repositoryDir.excludePatterns) |
| 1136 |
|
| 1137 |
def testConstructor_003(self): |
| 1138 |
""" |
| 1139 |
Test assignment of repositoryType attribute, None value. |
| 1140 |
""" |
| 1141 |
repositoryDir = RepositoryDir(repositoryType="type") |
| 1142 |
self.assertEqual("type", repositoryDir.repositoryType) |
| 1143 |
repositoryDir.repositoryType = None |
| 1144 |
self.assertEqual(None, repositoryDir.repositoryType) |
| 1145 |
|
| 1146 |
def testConstructor_004(self): |
| 1147 |
""" |
| 1148 |
Test assignment of repositoryType attribute, non-None value. |
| 1149 |
""" |
| 1150 |
repositoryDir = RepositoryDir() |
| 1151 |
self.assertEqual(None, repositoryDir.repositoryType) |
| 1152 |
repositoryDir.repositoryType = "" |
| 1153 |
self.assertEqual("", repositoryDir.repositoryType) |
| 1154 |
repositoryDir.repositoryType = "test" |
| 1155 |
self.assertEqual("test", repositoryDir.repositoryType) |
| 1156 |
|
| 1157 |
def testConstructor_005(self): |
| 1158 |
""" |
| 1159 |
Test assignment of directoryPath attribute, None value. |
| 1160 |
""" |
| 1161 |
repositoryDir = RepositoryDir(directoryPath="/path/to/something") |
| 1162 |
self.assertEqual("/path/to/something", repositoryDir.directoryPath) |
| 1163 |
repositoryDir.directoryPath = None |
| 1164 |
self.assertEqual(None, repositoryDir.directoryPath) |
| 1165 |
|
| 1166 |
def testConstructor_006(self): |
| 1167 |
""" |
| 1168 |
Test assignment of directoryPath attribute, valid value. |
| 1169 |
""" |
| 1170 |
repositoryDir = RepositoryDir() |
| 1171 |
self.assertEqual(None, repositoryDir.directoryPath) |
| 1172 |
repositoryDir.directoryPath = "/path/to/whatever" |
| 1173 |
self.assertEqual("/path/to/whatever", repositoryDir.directoryPath) |
| 1174 |
|
| 1175 |
def testConstructor_007(self): |
| 1176 |
""" |
| 1177 |
Test assignment of directoryPath attribute, invalid value (empty). |
| 1178 |
""" |
| 1179 |
repositoryDir = RepositoryDir() |
| 1180 |
self.assertEqual(None, repositoryDir.directoryPath) |
| 1181 |
self.failUnlessAssignRaises(ValueError, repositoryDir, "directoryPath", "") |
| 1182 |
self.assertEqual(None, repositoryDir.directoryPath) |
| 1183 |
|
| 1184 |
def testConstructor_008(self): |
| 1185 |
""" |
| 1186 |
Test assignment of directoryPath attribute, invalid value (not absolute). |
| 1187 |
""" |
| 1188 |
repositoryDir = RepositoryDir() |
| 1189 |
self.assertEqual(None, repositoryDir.directoryPath) |
| 1190 |
self.failUnlessAssignRaises(ValueError, repositoryDir, "directoryPath", "relative/path") |
| 1191 |
self.assertEqual(None, repositoryDir.directoryPath) |
| 1192 |
|
| 1193 |
def testConstructor_009(self): |
| 1194 |
""" |
| 1195 |
Test assignment of collectMode attribute, None value. |
| 1196 |
""" |
| 1197 |
repositoryDir = RepositoryDir(collectMode="daily") |
| 1198 |
self.assertEqual("daily", repositoryDir.collectMode) |
| 1199 |
repositoryDir.collectMode = None |
| 1200 |
self.assertEqual(None, repositoryDir.collectMode) |
| 1201 |
|
| 1202 |
def testConstructor_010(self): |
| 1203 |
""" |
| 1204 |
Test assignment of collectMode attribute, valid value. |
| 1205 |
""" |
| 1206 |
repositoryDir = RepositoryDir() |
| 1207 |
self.assertEqual(None, repositoryDir.collectMode) |
| 1208 |
repositoryDir.collectMode = "daily" |
| 1209 |
self.assertEqual("daily", repositoryDir.collectMode) |
| 1210 |
repositoryDir.collectMode = "weekly" |
| 1211 |
self.assertEqual("weekly", repositoryDir.collectMode) |
| 1212 |
repositoryDir.collectMode = "incr" |
| 1213 |
self.assertEqual("incr", repositoryDir.collectMode) |
| 1214 |
|
| 1215 |
def testConstructor_011(self): |
| 1216 |
""" |
| 1217 |
Test assignment of collectMode attribute, invalid value (empty). |
| 1218 |
""" |
| 1219 |
repositoryDir = RepositoryDir() |
| 1220 |
self.assertEqual(None, repositoryDir.collectMode) |
| 1221 |
self.failUnlessAssignRaises(ValueError, repositoryDir, "collectMode", "") |
| 1222 |
self.assertEqual(None, repositoryDir.collectMode) |
| 1223 |
|
| 1224 |
def testConstructor_012(self): |
| 1225 |
""" |
| 1226 |
Test assignment of collectMode attribute, invalid value (not in list). |
| 1227 |
""" |
| 1228 |
repositoryDir = RepositoryDir() |
| 1229 |
self.assertEqual(None, repositoryDir.collectMode) |
| 1230 |
self.failUnlessAssignRaises(ValueError, repositoryDir, "collectMode", "monthly") |
| 1231 |
self.assertEqual(None, repositoryDir.collectMode) |
| 1232 |
|
| 1233 |
def testConstructor_013(self): |
| 1234 |
""" |
| 1235 |
Test assignment of compressMode attribute, None value. |
| 1236 |
""" |
| 1237 |
repositoryDir = RepositoryDir(compressMode="gzip") |
| 1238 |
self.assertEqual("gzip", repositoryDir.compressMode) |
| 1239 |
repositoryDir.compressMode = None |
| 1240 |
self.assertEqual(None, repositoryDir.compressMode) |
| 1241 |
|
| 1242 |
def testConstructor_014(self): |
| 1243 |
""" |
| 1244 |
Test assignment of compressMode attribute, valid value. |
| 1245 |
""" |
| 1246 |
repositoryDir = RepositoryDir() |
| 1247 |
self.assertEqual(None, repositoryDir.compressMode) |
| 1248 |
repositoryDir.compressMode = "none" |
| 1249 |
self.assertEqual("none", repositoryDir.compressMode) |
| 1250 |
repositoryDir.compressMode = "bzip2" |
| 1251 |
self.assertEqual("bzip2", repositoryDir.compressMode) |
| 1252 |
repositoryDir.compressMode = "gzip" |
| 1253 |
self.assertEqual("gzip", repositoryDir.compressMode) |
| 1254 |
|
| 1255 |
def testConstructor_015(self): |
| 1256 |
""" |
| 1257 |
Test assignment of compressMode attribute, invalid value (empty). |
| 1258 |
""" |
| 1259 |
repositoryDir = RepositoryDir() |
| 1260 |
self.assertEqual(None, repositoryDir.compressMode) |
| 1261 |
self.failUnlessAssignRaises(ValueError, repositoryDir, "compressMode", "") |
| 1262 |
self.assertEqual(None, repositoryDir.compressMode) |
| 1263 |
|
| 1264 |
def testConstructor_016(self): |
| 1265 |
""" |
| 1266 |
Test assignment of compressMode attribute, invalid value (not in list). |
| 1267 |
""" |
| 1268 |
repositoryDir = RepositoryDir() |
| 1269 |
self.assertEqual(None, repositoryDir.compressMode) |
| 1270 |
self.failUnlessAssignRaises(ValueError, repositoryDir, "compressMode", "compress") |
| 1271 |
self.assertEqual(None, repositoryDir.compressMode) |
| 1272 |
|
| 1273 |
def testConstructor_017(self): |
| 1274 |
""" |
| 1275 |
Test assignment of relativeExcludePaths attribute, None value. |
| 1276 |
""" |
| 1277 |
repositoryDir = RepositoryDir(relativeExcludePaths=[]) |
| 1278 |
self.assertEqual([], repositoryDir.relativeExcludePaths) |
| 1279 |
repositoryDir.relativeExcludePaths = None |
| 1280 |
self.assertEqual(None, repositoryDir.relativeExcludePaths) |
| 1281 |
|
| 1282 |
def testConstructor_018(self): |
| 1283 |
""" |
| 1284 |
Test assignment of relativeExcludePaths attribute, [] value. |
| 1285 |
""" |
| 1286 |
repositoryDir = RepositoryDir() |
| 1287 |
self.assertEqual(None, repositoryDir.relativeExcludePaths) |
| 1288 |
repositoryDir.relativeExcludePaths = [] |
| 1289 |
self.assertEqual([], repositoryDir.relativeExcludePaths) |
| 1290 |
|
| 1291 |
def testConstructor_019(self): |
| 1292 |
""" |
| 1293 |
Test assignment of relativeExcludePaths attribute, single valid entry. |
| 1294 |
""" |
| 1295 |
repositoryDir = RepositoryDir() |
| 1296 |
self.assertEqual(None, repositoryDir.relativeExcludePaths) |
| 1297 |
repositoryDir.relativeExcludePaths = [ |
| 1298 |
"stuff", |
| 1299 |
] |
| 1300 |
self.assertEqual(["stuff"], repositoryDir.relativeExcludePaths) |
| 1301 |
repositoryDir.relativeExcludePaths.insert(0, "bogus") |
| 1302 |
self.assertEqual(["bogus", "stuff"], repositoryDir.relativeExcludePaths) |
| 1303 |
|
| 1304 |
def testConstructor_020(self): |
| 1305 |
""" |
| 1306 |
Test assignment of relativeExcludePaths attribute, multiple valid |
| 1307 |
entries. |
| 1308 |
""" |
| 1309 |
repositoryDir = RepositoryDir() |
| 1310 |
self.assertEqual(None, repositoryDir.relativeExcludePaths) |
| 1311 |
repositoryDir.relativeExcludePaths = [ |
| 1312 |
"bogus", |
| 1313 |
"stuff", |
| 1314 |
] |
| 1315 |
self.assertEqual(["bogus", "stuff"], repositoryDir.relativeExcludePaths) |
| 1316 |
repositoryDir.relativeExcludePaths.append("more") |
| 1317 |
self.assertEqual(["bogus", "stuff", "more"], repositoryDir.relativeExcludePaths) |
| 1318 |
|
| 1319 |
def testConstructor_021(self): |
| 1320 |
""" |
| 1321 |
Test assignment of excludePatterns attribute, None value. |
| 1322 |
""" |
| 1323 |
repositoryDir = RepositoryDir(excludePatterns=[]) |
| 1324 |
self.assertEqual([], repositoryDir.excludePatterns) |
| 1325 |
repositoryDir.excludePatterns = None |
| 1326 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1327 |
|
| 1328 |
def testConstructor_022(self): |
| 1329 |
""" |
| 1330 |
Test assignment of excludePatterns attribute, [] value. |
| 1331 |
""" |
| 1332 |
repositoryDir = RepositoryDir() |
| 1333 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1334 |
repositoryDir.excludePatterns = [] |
| 1335 |
self.assertEqual([], repositoryDir.excludePatterns) |
| 1336 |
|
| 1337 |
def testConstructor_023(self): |
| 1338 |
""" |
| 1339 |
Test assignment of excludePatterns attribute, single valid entry. |
| 1340 |
""" |
| 1341 |
repositoryDir = RepositoryDir() |
| 1342 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1343 |
repositoryDir.excludePatterns = [ |
| 1344 |
"valid", |
| 1345 |
] |
| 1346 |
self.assertEqual(["valid"], repositoryDir.excludePatterns) |
| 1347 |
repositoryDir.excludePatterns.append("more") |
| 1348 |
self.assertEqual(["valid", "more"], repositoryDir.excludePatterns) |
| 1349 |
|
| 1350 |
def testConstructor_024(self): |
| 1351 |
""" |
| 1352 |
Test assignment of excludePatterns attribute, multiple valid entries. |
| 1353 |
""" |
| 1354 |
repositoryDir = RepositoryDir() |
| 1355 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1356 |
repositoryDir.excludePatterns = [ |
| 1357 |
"valid", |
| 1358 |
"more", |
| 1359 |
] |
| 1360 |
self.assertEqual(["valid", "more"], repositoryDir.excludePatterns) |
| 1361 |
repositoryDir.excludePatterns.insert(1, "bogus") |
| 1362 |
self.assertEqual(["valid", "bogus", "more"], repositoryDir.excludePatterns) |
| 1363 |
|
| 1364 |
def testConstructor_025(self): |
| 1365 |
""" |
| 1366 |
Test assignment of excludePatterns attribute, single invalid entry. |
| 1367 |
""" |
| 1368 |
repositoryDir = RepositoryDir() |
| 1369 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1370 |
self.failUnlessAssignRaises(ValueError, repositoryDir, "excludePatterns", ["*.jpg"]) |
| 1371 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1372 |
|
| 1373 |
def testConstructor_026(self): |
| 1374 |
""" |
| 1375 |
Test assignment of excludePatterns attribute, multiple invalid entries. |
| 1376 |
""" |
| 1377 |
repositoryDir = RepositoryDir() |
| 1378 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1379 |
self.failUnlessAssignRaises(ValueError, repositoryDir, "excludePatterns", ["*.jpg", "*"]) |
| 1380 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1381 |
|
| 1382 |
def testConstructor_027(self): |
| 1383 |
""" |
| 1384 |
Test assignment of excludePatterns attribute, mixed valid and invalid |
| 1385 |
entries. |
| 1386 |
""" |
| 1387 |
repositoryDir = RepositoryDir() |
| 1388 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1389 |
self.failUnlessAssignRaises(ValueError, repositoryDir, "excludePatterns", ["*.jpg", "valid"]) |
| 1390 |
self.assertEqual(None, repositoryDir.excludePatterns) |
| 1391 |
|
| 1392 |
############################ |
| 1393 |
# Test comparison operators |
| 1394 |
############################ |
| 1395 |
|
| 1396 |
def testComparison_001(self): |
| 1397 |
""" |
| 1398 |
Test comparison of two identical objects, all attributes None. |
| 1399 |
""" |
| 1400 |
repositoryDir1 = RepositoryDir() |
| 1401 |
repositoryDir2 = RepositoryDir() |
| 1402 |
self.assertEqual(repositoryDir1, repositoryDir2) |
| 1403 |
self.assertTrue(repositoryDir1 == repositoryDir2) |
| 1404 |
self.assertTrue(not repositoryDir1 < repositoryDir2) |
| 1405 |
self.assertTrue(repositoryDir1 <= repositoryDir2) |
| 1406 |
self.assertTrue(not repositoryDir1 > repositoryDir2) |
| 1407 |
self.assertTrue(repositoryDir1 >= repositoryDir2) |
| 1408 |
self.assertTrue(not repositoryDir1 != repositoryDir2) |
| 1409 |
|
| 1410 |
def testComparison_002(self): |
| 1411 |
""" |
| 1412 |
Test comparison of two identical objects, all attributes non-None. |
| 1413 |
""" |
| 1414 |
repositoryDir1 = RepositoryDir("type", "/path", "daily", "gzip") |
| 1415 |
repositoryDir2 = RepositoryDir("type", "/path", "daily", "gzip") |
| 1416 |
self.assertEqual(repositoryDir1, repositoryDir2) |
| 1417 |
self.assertTrue(repositoryDir1 == repositoryDir2) |
| 1418 |
self.assertTrue(not repositoryDir1 < repositoryDir2) |
| 1419 |
self.assertTrue(repositoryDir1 <= repositoryDir2) |
| 1420 |
self.assertTrue(not repositoryDir1 > repositoryDir2) |
| 1421 |
self.assertTrue(repositoryDir1 >= repositoryDir2) |
| 1422 |
self.assertTrue(not repositoryDir1 != repositoryDir2) |
| 1423 |
|
| 1424 |
def testComparison_003(self): |
| 1425 |
""" |
| 1426 |
Test comparison of two differing objects, repositoryType differs (one None). |
| 1427 |
""" |
| 1428 |
repositoryDir1 = RepositoryDir() |
| 1429 |
repositoryDir2 = RepositoryDir(repositoryType="type") |
| 1430 |
self.assertNotEqual(repositoryDir1, repositoryDir2) |
| 1431 |
self.assertTrue(not repositoryDir1 == repositoryDir2) |
| 1432 |
self.assertTrue(repositoryDir1 < repositoryDir2) |
| 1433 |
self.assertTrue(repositoryDir1 <= repositoryDir2) |
| 1434 |
self.assertTrue(not repositoryDir1 > repositoryDir2) |
| 1435 |
self.assertTrue(not repositoryDir1 >= repositoryDir2) |
| 1436 |
self.assertTrue(repositoryDir1 != repositoryDir2) |
| 1437 |
|
| 1438 |
def testComparison_004(self): |
| 1439 |
""" |
| 1440 |
Test comparison of two differing objects, repositoryType differs. |
| 1441 |
""" |
| 1442 |
repositoryDir1 = RepositoryDir("other", "/path", "daily", "gzip") |
| 1443 |
repositoryDir2 = RepositoryDir("type", "/path", "daily", "gzip") |
| 1444 |
self.assertNotEqual(repositoryDir1, repositoryDir2) |
| 1445 |
self.assertTrue(not repositoryDir1 == repositoryDir2) |
| 1446 |
self.assertTrue(repositoryDir1 < repositoryDir2) |
| 1447 |
self.assertTrue(repositoryDir1 <= repositoryDir2) |
| 1448 |
self.assertTrue(not repositoryDir1 > repositoryDir2) |
| 1449 |
self.assertTrue(not repositoryDir1 >= repositoryDir2) |
| 1450 |
self.assertTrue(repositoryDir1 != repositoryDir2) |
| 1451 |
|
| 1452 |
def testComparison_004a(self): |
| 1453 |
""" |
| 1454 |
Test comparison of two differing objects, directoryPath differs (one None). |
| 1455 |
""" |
| 1456 |
repositoryDir1 = RepositoryDir() |
| 1457 |
repositoryDir2 = RepositoryDir(directoryPath="/zippy") |
| 1458 |
self.assertNotEqual(repositoryDir1, repositoryDir2) |
| 1459 |
self.assertTrue(not repositoryDir1 == repositoryDir2) |
| 1460 |
self.assertTrue(repositoryDir1 < repositoryDir2) |
| 1461 |
self.assertTrue(repositoryDir1 <= repositoryDir2) |
| 1462 |
self.assertTrue(not repositoryDir1 > repositoryDir2) |
| 1463 |
self.assertTrue(not repositoryDir1 >= repositoryDir2) |
| 1464 |
self.assertTrue(repositoryDir1 != repositoryDir2) |
| 1465 |
|
| 1466 |
def testComparison_005(self): |
| 1467 |
""" |
| 1468 |
Test comparison of two differing objects, directoryPath differs. |
| 1469 |
""" |
| 1470 |
repositoryDir1 = RepositoryDir("type", "/path", "daily", "gzip") |
| 1471 |
repositoryDir2 = RepositoryDir("type", "/zippy", "daily", "gzip") |
| 1472 |
self.assertNotEqual(repositoryDir1, repositoryDir2) |
| 1473 |
self.assertTrue(not repositoryDir1 == repositoryDir2) |
| 1474 |
self.assertTrue(repositoryDir1 < repositoryDir2) |
| 1475 |
self.assertTrue(repositoryDir1 <= repositoryDir2) |
| 1476 |
self.assertTrue(not repositoryDir1 > repositoryDir2) |
| 1477 |
self.assertTrue(not repositoryDir1 >= repositoryDir2) |
| 1478 |
self.assertTrue(repositoryDir1 != repositoryDir2) |
| 1479 |
|
| 1480 |
def testComparison_006(self): |
| 1481 |
""" |
| 1482 |
Test comparison of two differing objects, collectMode differs (one None). |
| 1483 |
""" |
| 1484 |
repositoryDir1 = RepositoryDir() |
| 1485 |
repositoryDir2 = RepositoryDir(collectMode="incr") |
| 1486 |
self.assertNotEqual(repositoryDir1, repositoryDir2) |
| 1487 |
self.assertTrue(not repositoryDir1 == repositoryDir2) |
| 1488 |
self.assertTrue(repositoryDir1 < repositoryDir2) |
| 1489 |
self.assertTrue(repositoryDir1 <= repositoryDir2) |
| 1490 |
self.assertTrue(not repositoryDir1 > repositoryDir2) |
| 1491 |
self.assertTrue(not repositoryDir1 >= repositoryDir2) |
| 1492 |
self.assertTrue(repositoryDir1 != repositoryDir2) |
| 1493 |
|
| 1494 |
def testComparison_007(self): |
| 1495 |
""" |
| 1496 |
Test comparison of two differing objects, collectMode differs. |
| 1497 |
""" |
| 1498 |
repositoryDir1 = RepositoryDir("type", "/path", "daily", "gzip") |
| 1499 |
repositoryDir2 = RepositoryDir("type", "/path", "incr", "gzip") |
| 1500 |
self.assertNotEqual(repositoryDir1, repositoryDir2) |
| 1501 |
self.assertTrue(not repositoryDir1 == repositoryDir2) |
| 1502 |
self.assertTrue(repositoryDir1 < repositoryDir2) |
| 1503 |
self.assertTrue(repositoryDir1 <= repositoryDir2) |
| 1504 |
self.assertTrue(not repositoryDir1 > repositoryDir2) |
| 1505 |
self.assertTrue(not repositoryDir1 >= repositoryDir2) |
| 1506 |
self.assertTrue(repositoryDir1 != repositoryDir2) |
| 1507 |
|
| 1508 |
def testComparison_008(self): |
| 1509 |
""" |
| 1510 |
Test comparison of two differing objects, compressMode differs (one None). |
| 1511 |
""" |
| 1512 |
repositoryDir1 = RepositoryDir() |
| 1513 |
repositoryDir2 = RepositoryDir(compressMode="gzip") |
| 1514 |
self.assertNotEqual(repositoryDir1, repositoryDir2) |
| 1515 |
self.assertTrue(not repositoryDir1 == repositoryDir2) |
| 1516 |
self.assertTrue(repositoryDir1 < repositoryDir2) |
| 1517 |
self.assertTrue(repositoryDir1 <= repositoryDir2) |
| 1518 |
self.assertTrue(not repositoryDir1 > repositoryDir2) |
| 1519 |
self.assertTrue(not repositoryDir1 >= repositoryDir2) |
| 1520 |
self.assertTrue(repositoryDir1 != repositoryDir2) |
| 1521 |
|
| 1522 |
def testComparison_009(self): |
| 1523 |
""" |
| 1524 |
Test comparison of two differing objects, compressMode differs. |
| 1525 |
""" |
| 1526 |
repositoryDir1 = RepositoryDir("type", "/path", "daily", "bzip2") |
| 1527 |
repositoryDir2 = RepositoryDir("type", "/path", "daily", "gzip") |
| 1528 |
self.assertNotEqual(repositoryDir1, repositoryDir2) |
| 1529 |
self.assertTrue(not repositoryDir1 == repositoryDir2) |
| 1530 |
self.assertTrue(repositoryDir1 < repositoryDir2) |
| 1531 |
self.assertTrue(repositoryDir1 <= repositoryDir2) |
| 1532 |
self.assertTrue(not repositoryDir1 > repositoryDir2) |
| 1533 |
self.assertTrue(not repositoryDir1 >= repositoryDir2) |
| 1534 |
self.assertTrue(repositoryDir1 != repositoryDir2) |
| 1535 |
|
| 1536 |
|
| 1537 |
############################# |
| 1538 |
# TestSubversionConfig class |
| 1539 |
############################# |
| 1540 |
|
| 1541 |
|
| 1542 |
class TestSubversionConfig(unittest.TestCase): |
| 1543 |
"""Tests for the SubversionConfig class.""" |
| 1544 |
|
| 1545 |
################ |
| 1546 |
# Setup methods |
| 1547 |
################ |
| 1548 |
|
| 1549 |
@classmethod |
| 1550 |
def setUpClass(cls): |
| 1551 |
configureLogging() |
| 1552 |
|
| 1553 |
################## |
| 1554 |
# Utility methods |
| 1555 |
################## |
| 1556 |
|
| 1557 |
def failUnlessAssignRaises(self, exception, obj, prop, value): |
| 1558 |
"""Equivalent of :any:`failUnlessRaises`, but used for property assignments instead.""" |
| 1559 |
failUnlessAssignRaises(self, exception, obj, prop, value) |
| 1560 |
|
| 1561 |
############################ |
| 1562 |
# Test __repr__ and __str__ |
| 1563 |
############################ |
| 1564 |
|
| 1565 |
def testStringFuncs_001(self): |
| 1566 |
""" |
| 1567 |
Just make sure that the string functions don't have errors (i.e. bad variable names). |
| 1568 |
""" |
| 1569 |
obj = SubversionConfig() |
| 1570 |
obj.__repr__() |
| 1571 |
obj.__str__() |
| 1572 |
|
| 1573 |
################################## |
| 1574 |
# Test constructor and attributes |
| 1575 |
################################## |
| 1576 |
|
| 1577 |
def testConstructor_001(self): |
| 1578 |
""" |
| 1579 |
Test constructor with no values filled in. |
| 1580 |
""" |
| 1581 |
subversion = SubversionConfig() |
| 1582 |
self.assertEqual(None, subversion.collectMode) |
| 1583 |
self.assertEqual(None, subversion.compressMode) |
| 1584 |
self.assertEqual(None, subversion.repositories) |
| 1585 |
|
| 1586 |
def testConstructor_002(self): |
| 1587 |
""" |
| 1588 |
Test constructor with all values filled in, with valid values, repositories=None. |
| 1589 |
""" |
| 1590 |
subversion = SubversionConfig("daily", "gzip", None) |
| 1591 |
self.assertEqual("daily", subversion.collectMode) |
| 1592 |
self.assertEqual("gzip", subversion.compressMode) |
| 1593 |
self.assertEqual(None, subversion.repositories) |
| 1594 |
|
| 1595 |
def testConstructor_003(self): |
| 1596 |
""" |
| 1597 |
Test constructor with all values filled in, with valid values, no repositories. |
| 1598 |
""" |
| 1599 |
subversion = SubversionConfig("daily", "gzip", []) |
| 1600 |
self.assertEqual("daily", subversion.collectMode) |
| 1601 |
self.assertEqual("gzip", subversion.compressMode) |
| 1602 |
self.assertEqual([], subversion.repositories) |
| 1603 |
|
| 1604 |
def testConstructor_004(self): |
| 1605 |
""" |
| 1606 |
Test constructor with all values filled in, with valid values, with one repository. |
| 1607 |
""" |
| 1608 |
repositories = [ |
| 1609 |
Repository(), |
| 1610 |
] |
| 1611 |
subversion = SubversionConfig("daily", "gzip", repositories) |
| 1612 |
self.assertEqual("daily", subversion.collectMode) |
| 1613 |
self.assertEqual("gzip", subversion.compressMode) |
| 1614 |
self.assertEqual(repositories, subversion.repositories) |
| 1615 |
|
| 1616 |
def testConstructor_005(self): |
| 1617 |
""" |
| 1618 |
Test constructor with all values filled in, with valid values, with multiple repositories. |
| 1619 |
""" |
| 1620 |
repositories = [ |
| 1621 |
Repository(collectMode="daily"), |
| 1622 |
Repository(collectMode="weekly"), |
| 1623 |
] |
| 1624 |
subversion = SubversionConfig("daily", "gzip", repositories=repositories) |
| 1625 |
self.assertEqual("daily", subversion.collectMode) |
| 1626 |
self.assertEqual("gzip", subversion.compressMode) |
| 1627 |
self.assertEqual(repositories, subversion.repositories) |
| 1628 |
|
| 1629 |
def testConstructor_006(self): |
| 1630 |
""" |
| 1631 |
Test assignment of collectMode attribute, None value. |
| 1632 |
""" |
| 1633 |
subversion = SubversionConfig(collectMode="daily") |
| 1634 |
self.assertEqual("daily", subversion.collectMode) |
| 1635 |
subversion.collectMode = None |
| 1636 |
self.assertEqual(None, subversion.collectMode) |
| 1637 |
|
| 1638 |
def testConstructor_007(self): |
| 1639 |
""" |
| 1640 |
Test assignment of collectMode attribute, valid value. |
| 1641 |
""" |
| 1642 |
subversion = SubversionConfig() |
| 1643 |
self.assertEqual(None, subversion.collectMode) |
| 1644 |
subversion.collectMode = "weekly" |
| 1645 |
self.assertEqual("weekly", subversion.collectMode) |
| 1646 |
|
| 1647 |
def testConstructor_008(self): |
| 1648 |
""" |
| 1649 |
Test assignment of collectMode attribute, invalid value (empty). |
| 1650 |
""" |
| 1651 |
subversion = SubversionConfig() |
| 1652 |
self.assertEqual(None, subversion.collectMode) |
| 1653 |
self.failUnlessAssignRaises(ValueError, subversion, "collectMode", "") |
| 1654 |
self.assertEqual(None, subversion.collectMode) |
| 1655 |
|
| 1656 |
def testConstructor_009(self): |
| 1657 |
""" |
| 1658 |
Test assignment of compressMode attribute, None value. |
| 1659 |
""" |
| 1660 |
subversion = SubversionConfig(compressMode="gzip") |
| 1661 |
self.assertEqual("gzip", subversion.compressMode) |
| 1662 |
subversion.compressMode = None |
| 1663 |
self.assertEqual(None, subversion.compressMode) |
| 1664 |
|
| 1665 |
def testConstructor_010(self): |
| 1666 |
""" |
| 1667 |
Test assignment of compressMode attribute, valid value. |
| 1668 |
""" |
| 1669 |
subversion = SubversionConfig() |
| 1670 |
self.assertEqual(None, subversion.compressMode) |
| 1671 |
subversion.compressMode = "bzip2" |
| 1672 |
self.assertEqual("bzip2", subversion.compressMode) |
| 1673 |
|
| 1674 |
def testConstructor_011(self): |
| 1675 |
""" |
| 1676 |
Test assignment of compressMode attribute, invalid value (empty). |
| 1677 |
""" |
| 1678 |
subversion = SubversionConfig() |
| 1679 |
self.assertEqual(None, subversion.compressMode) |
| 1680 |
self.failUnlessAssignRaises(ValueError, subversion, "compressMode", "") |
| 1681 |
self.assertEqual(None, subversion.compressMode) |
| 1682 |
|
| 1683 |
def testConstructor_012(self): |
| 1684 |
""" |
| 1685 |
Test assignment of repositories attribute, None value. |
| 1686 |
""" |
| 1687 |
subversion = SubversionConfig(repositories=[]) |
| 1688 |
self.assertEqual([], subversion.repositories) |
| 1689 |
subversion.repositories = None |
| 1690 |
self.assertEqual(None, subversion.repositories) |
| 1691 |
|
| 1692 |
def testConstructor_013(self): |
| 1693 |
""" |
| 1694 |
Test assignment of repositories attribute, [] value. |
| 1695 |
""" |
| 1696 |
subversion = SubversionConfig() |
| 1697 |
self.assertEqual(None, subversion.repositories) |
| 1698 |
subversion.repositories = [] |
| 1699 |
self.assertEqual([], subversion.repositories) |
| 1700 |
|
| 1701 |
def testConstructor_014(self): |
| 1702 |
""" |
| 1703 |
Test assignment of repositories attribute, single valid entry. |
| 1704 |
""" |
| 1705 |
subversion = SubversionConfig() |
| 1706 |
self.assertEqual(None, subversion.repositories) |
| 1707 |
subversion.repositories = [ |
| 1708 |
Repository(), |
| 1709 |
] |
| 1710 |
self.assertEqual([Repository()], subversion.repositories) |
| 1711 |
subversion.repositories.append(Repository(collectMode="daily")) |
| 1712 |
self.assertEqual([Repository(), Repository(collectMode="daily")], subversion.repositories) |
| 1713 |
|
| 1714 |
def testConstructor_015(self): |
| 1715 |
""" |
| 1716 |
Test assignment of repositories attribute, multiple valid entries. |
| 1717 |
""" |
| 1718 |
subversion = SubversionConfig() |
| 1719 |
self.assertEqual(None, subversion.repositories) |
| 1720 |
subversion.repositories = [ |
| 1721 |
Repository(collectMode="daily"), |
| 1722 |
Repository(collectMode="weekly"), |
| 1723 |
] |
| 1724 |
self.assertEqual([Repository(collectMode="daily"), Repository(collectMode="weekly")], subversion.repositories) |
| 1725 |
subversion.repositories.append(Repository(collectMode="incr")) |
| 1726 |
self.assertEqual( |
| 1727 |
[Repository(collectMode="daily"), Repository(collectMode="weekly"), Repository(collectMode="incr")], |
| 1728 |
subversion.repositories, |
| 1729 |
) |
| 1730 |
|
| 1731 |
def testConstructor_016(self): |
| 1732 |
""" |
| 1733 |
Test assignment of repositories attribute, single invalid entry (None). |
| 1734 |
""" |
| 1735 |
subversion = SubversionConfig() |
| 1736 |
self.assertEqual(None, subversion.repositories) |
| 1737 |
self.failUnlessAssignRaises(ValueError, subversion, "repositories", [None]) |
| 1738 |
self.assertEqual(None, subversion.repositories) |
| 1739 |
|
| 1740 |
def testConstructor_017(self): |
| 1741 |
""" |
| 1742 |
Test assignment of repositories attribute, single invalid entry (wrong type). |
| 1743 |
""" |
| 1744 |
subversion = SubversionConfig() |
| 1745 |
self.assertEqual(None, subversion.repositories) |
| 1746 |
self.failUnlessAssignRaises(ValueError, subversion, "repositories", [SubversionConfig()]) |
| 1747 |
self.assertEqual(None, subversion.repositories) |
| 1748 |
|
| 1749 |
def testConstructor_018(self): |
| 1750 |
""" |
| 1751 |
Test assignment of repositories attribute, mixed valid and invalid entries. |
| 1752 |
""" |
| 1753 |
subversion = SubversionConfig() |
| 1754 |
self.assertEqual(None, subversion.repositories) |
| 1755 |
self.failUnlessAssignRaises(ValueError, subversion, "repositories", [Repository(), SubversionConfig()]) |
| 1756 |
self.assertEqual(None, subversion.repositories) |
| 1757 |
|
| 1758 |
############################ |
| 1759 |
# Test comparison operators |
| 1760 |
############################ |
| 1761 |
|
| 1762 |
def testComparison_001(self): |
| 1763 |
""" |
| 1764 |
Test comparison of two identical objects, all attributes None. |
| 1765 |
""" |
| 1766 |
subversion1 = SubversionConfig() |
| 1767 |
subversion2 = SubversionConfig() |
| 1768 |
self.assertEqual(subversion1, subversion2) |
| 1769 |
self.assertTrue(subversion1 == subversion2) |
| 1770 |
self.assertTrue(not subversion1 < subversion2) |
| 1771 |
self.assertTrue(subversion1 <= subversion2) |
| 1772 |
self.assertTrue(not subversion1 > subversion2) |
| 1773 |
self.assertTrue(subversion1 >= subversion2) |
| 1774 |
self.assertTrue(not subversion1 != subversion2) |
| 1775 |
|
| 1776 |
def testComparison_002(self): |
| 1777 |
""" |
| 1778 |
Test comparison of two identical objects, all attributes non-None, list None. |
| 1779 |
""" |
| 1780 |
subversion1 = SubversionConfig("daily", "gzip", None) |
| 1781 |
subversion2 = SubversionConfig("daily", "gzip", None) |
| 1782 |
self.assertEqual(subversion1, subversion2) |
| 1783 |
self.assertTrue(subversion1 == subversion2) |
| 1784 |
self.assertTrue(not subversion1 < subversion2) |
| 1785 |
self.assertTrue(subversion1 <= subversion2) |
| 1786 |
self.assertTrue(not subversion1 > subversion2) |
| 1787 |
self.assertTrue(subversion1 >= subversion2) |
| 1788 |
self.assertTrue(not subversion1 != subversion2) |
| 1789 |
|
| 1790 |
def testComparison_003(self): |
| 1791 |
""" |
| 1792 |
Test comparison of two identical objects, all attributes non-None, list empty. |
| 1793 |
""" |
| 1794 |
subversion1 = SubversionConfig("daily", "gzip", []) |
| 1795 |
subversion2 = SubversionConfig("daily", "gzip", []) |
| 1796 |
self.assertEqual(subversion1, subversion2) |
| 1797 |
self.assertTrue(subversion1 == subversion2) |
| 1798 |
self.assertTrue(not subversion1 < subversion2) |
| 1799 |
self.assertTrue(subversion1 <= subversion2) |
| 1800 |
self.assertTrue(not subversion1 > subversion2) |
| 1801 |
self.assertTrue(subversion1 >= subversion2) |
| 1802 |
self.assertTrue(not subversion1 != subversion2) |
| 1803 |
|
| 1804 |
def testComparison_004(self): |
| 1805 |
""" |
| 1806 |
Test comparison of two identical objects, all attributes non-None, list non-empty. |
| 1807 |
""" |
| 1808 |
subversion1 = SubversionConfig("daily", "gzip", [Repository()]) |
| 1809 |
subversion2 = SubversionConfig("daily", "gzip", [Repository()]) |
| 1810 |
self.assertEqual(subversion1, subversion2) |
| 1811 |
self.assertTrue(subversion1 == subversion2) |
| 1812 |
self.assertTrue(not subversion1 < subversion2) |
| 1813 |
self.assertTrue(subversion1 <= subversion2) |
| 1814 |
self.assertTrue(not subversion1 > subversion2) |
| 1815 |
self.assertTrue(subversion1 >= subversion2) |
| 1816 |
self.assertTrue(not subversion1 != subversion2) |
| 1817 |
|
| 1818 |
def testComparison_005(self): |
| 1819 |
""" |
| 1820 |
Test comparison of two differing objects, collectMode differs (one None). |
| 1821 |
""" |
| 1822 |
subversion1 = SubversionConfig() |
| 1823 |
subversion2 = SubversionConfig(collectMode="daily") |
| 1824 |
self.assertNotEqual(subversion1, subversion2) |
| 1825 |
self.assertTrue(not subversion1 == subversion2) |
| 1826 |
self.assertTrue(subversion1 < subversion2) |
| 1827 |
self.assertTrue(subversion1 <= subversion2) |
| 1828 |
self.assertTrue(not subversion1 > subversion2) |
| 1829 |
self.assertTrue(not subversion1 >= subversion2) |
| 1830 |
self.assertTrue(subversion1 != subversion2) |
| 1831 |
|
| 1832 |
def testComparison_006(self): |
| 1833 |
""" |
| 1834 |
Test comparison of two differing objects, collectMode differs. |
| 1835 |
""" |
| 1836 |
subversion1 = SubversionConfig("daily", "gzip", [Repository()]) |
| 1837 |
subversion2 = SubversionConfig("weekly", "gzip", [Repository()]) |
| 1838 |
self.assertNotEqual(subversion1, subversion2) |
| 1839 |
self.assertTrue(not subversion1 == subversion2) |
| 1840 |
self.assertTrue(subversion1 < subversion2) |
| 1841 |
self.assertTrue(subversion1 <= subversion2) |
| 1842 |
self.assertTrue(not subversion1 > subversion2) |
| 1843 |
self.assertTrue(not subversion1 >= subversion2) |
| 1844 |
self.assertTrue(subversion1 != subversion2) |
| 1845 |
|
| 1846 |
def testComparison_007(self): |
| 1847 |
""" |
| 1848 |
Test comparison of two differing objects, compressMode differs (one None). |
| 1849 |
""" |
| 1850 |
subversion1 = SubversionConfig() |
| 1851 |
subversion2 = SubversionConfig(compressMode="bzip2") |
| 1852 |
self.assertNotEqual(subversion1, subversion2) |
| 1853 |
self.assertTrue(not subversion1 == subversion2) |
| 1854 |
self.assertTrue(subversion1 < subversion2) |
| 1855 |
self.assertTrue(subversion1 <= subversion2) |
| 1856 |
self.assertTrue(not subversion1 > subversion2) |
| 1857 |
self.assertTrue(not subversion1 >= subversion2) |
| 1858 |
self.assertTrue(subversion1 != subversion2) |
| 1859 |
|
| 1860 |
def testComparison_008(self): |
| 1861 |
""" |
| 1862 |
Test comparison of two differing objects, compressMode differs. |
| 1863 |
""" |
| 1864 |
subversion1 = SubversionConfig("daily", "bzip2", [Repository()]) |
| 1865 |
subversion2 = SubversionConfig("daily", "gzip", [Repository()]) |
| 1866 |
self.assertNotEqual(subversion1, subversion2) |
| 1867 |
self.assertTrue(not subversion1 == subversion2) |
| 1868 |
self.assertTrue(subversion1 < subversion2) |
| 1869 |
self.assertTrue(subversion1 <= subversion2) |
| 1870 |
self.assertTrue(not subversion1 > subversion2) |
| 1871 |
self.assertTrue(not subversion1 >= subversion2) |
| 1872 |
self.assertTrue(subversion1 != subversion2) |
| 1873 |
|
| 1874 |
def testComparison_009(self): |
| 1875 |
""" |
| 1876 |
Test comparison of two differing objects, repositories differs (one None, one empty). |
| 1877 |
""" |
| 1878 |
subversion1 = SubversionConfig() |
| 1879 |
subversion2 = SubversionConfig(repositories=[]) |
| 1880 |
self.assertNotEqual(subversion1, subversion2) |
| 1881 |
self.assertTrue(not subversion1 == subversion2) |
| 1882 |
self.assertTrue(subversion1 < subversion2) |
| 1883 |
self.assertTrue(subversion1 <= subversion2) |
| 1884 |
self.assertTrue(not subversion1 > subversion2) |
| 1885 |
self.assertTrue(not subversion1 >= subversion2) |
| 1886 |
self.assertTrue(subversion1 != subversion2) |
| 1887 |
|
| 1888 |
def testComparison_010(self): |
| 1889 |
""" |
| 1890 |
Test comparison of two differing objects, repositories differs (one None, one not empty). |
| 1891 |
""" |
| 1892 |
subversion1 = SubversionConfig() |
| 1893 |
subversion2 = SubversionConfig(repositories=[Repository()]) |
| 1894 |
self.assertNotEqual(subversion1, subversion2) |
| 1895 |
self.assertTrue(not subversion1 == subversion2) |
| 1896 |
self.assertTrue(subversion1 < subversion2) |
| 1897 |
self.assertTrue(subversion1 <= subversion2) |
| 1898 |
self.assertTrue(not subversion1 > subversion2) |
| 1899 |
self.assertTrue(not subversion1 >= subversion2) |
| 1900 |
self.assertTrue(subversion1 != subversion2) |
| 1901 |
|
| 1902 |
def testComparison_011(self): |
| 1903 |
""" |
| 1904 |
Test comparison of two differing objects, repositories differs (one empty, one not empty). |
| 1905 |
""" |
| 1906 |
subversion1 = SubversionConfig("daily", "gzip", []) |
| 1907 |
subversion2 = SubversionConfig("daily", "gzip", [Repository()]) |
| 1908 |
self.assertNotEqual(subversion1, subversion2) |
| 1909 |
self.assertTrue(not subversion1 == subversion2) |
| 1910 |
self.assertTrue(subversion1 < subversion2) |
| 1911 |
self.assertTrue(subversion1 <= subversion2) |
| 1912 |
self.assertTrue(not subversion1 > subversion2) |
| 1913 |
self.assertTrue(not subversion1 >= subversion2) |
| 1914 |
self.assertTrue(subversion1 != subversion2) |
| 1915 |
|
| 1916 |
def testComparison_012(self): |
| 1917 |
""" |
| 1918 |
Test comparison of two differing objects, repositories differs (both not empty). |
| 1919 |
""" |
| 1920 |
subversion1 = SubversionConfig("daily", "gzip", [Repository()]) |
| 1921 |
subversion2 = SubversionConfig("daily", "gzip", [Repository(), Repository()]) |
| 1922 |
self.assertNotEqual(subversion1, subversion2) |
| 1923 |
self.assertTrue(not subversion1 == subversion2) |
| 1924 |
self.assertTrue(subversion1 < subversion2) |
| 1925 |
self.assertTrue(subversion1 <= subversion2) |
| 1926 |
self.assertTrue(not subversion1 > subversion2) |
| 1927 |
self.assertTrue(not subversion1 >= subversion2) |
| 1928 |
self.assertTrue(subversion1 != subversion2) |
| 1929 |
|
| 1930 |
def testComparison_013(self): |
| 1931 |
""" |
| 1932 |
Test comparison of two differing objects, repositories differs (both not empty). |
| 1933 |
""" |
| 1934 |
subversion1 = SubversionConfig("daily", "gzip", [Repository(repositoryType="other")]) |
| 1935 |
subversion2 = SubversionConfig("daily", "gzip", [Repository(repositoryType="type")]) |
| 1936 |
self.assertNotEqual(subversion1, subversion2) |
| 1937 |
self.assertTrue(not subversion1 == subversion2) |
| 1938 |
self.assertTrue(subversion1 < subversion2) |
| 1939 |
self.assertTrue(subversion1 <= subversion2) |
| 1940 |
self.assertTrue(not subversion1 > subversion2) |
| 1941 |
self.assertTrue(not subversion1 >= subversion2) |
| 1942 |
self.assertTrue(subversion1 != subversion2) |
| 1943 |
|
| 1944 |
|
| 1945 |
######################## |
| 1946 |
# TestLocalConfig class |
| 1947 |
######################## |
| 1948 |
|
| 1949 |
|
| 1950 |
class TestLocalConfig(unittest.TestCase): |
| 1951 |
"""Tests for the LocalConfig class.""" |
| 1952 |
|
| 1953 |
################ |
| 1954 |
# Setup methods |
| 1955 |
################ |
| 1956 |
|
| 1957 |
@classmethod |
| 1958 |
def setUpClass(cls): |
| 1959 |
configureLogging() |
| 1960 |
|
| 1961 |
################ |
| 1962 |
# Setup methods |
| 1963 |
################ |
| 1964 |
|
| 1965 |
def setUp(self): |
| 1966 |
try: |
| 1967 |
self.resources = findResources(RESOURCES, DATA_DIRS) |
| 1968 |
except Exception as e: |
| 1969 |
self.fail(e) |
| 1970 |
|
| 1971 |
def tearDown(self): |
| 1972 |
pass |
| 1973 |
|
| 1974 |
################## |
| 1975 |
# Utility methods |
| 1976 |
################## |
| 1977 |
|
| 1978 |
def failUnlessAssignRaises(self, exception, obj, prop, value): |
| 1979 |
"""Equivalent of :any:`failUnlessRaises`, but used for property assignments instead.""" |
| 1980 |
failUnlessAssignRaises(self, exception, obj, prop, value) |
| 1981 |
|
| 1982 |
def validateAddConfig(self, origConfig): |
| 1983 |
""" |
| 1984 |
Validates that document dumped from ``LocalConfig.addConfig`` results in |
| 1985 |
identical object. |
| 1986 |
|
| 1987 |
We dump a document containing just the subversion configuration, and then |
| 1988 |
make sure that if we push that document back into the ``LocalConfig`` |
| 1989 |
object, that the resulting object matches the original. |
| 1990 |
|
| 1991 |
The ``self.failUnlessEqual`` method is used for the validation, so if the |
| 1992 |
method call returns normally, everything is OK. |
| 1993 |
|
| 1994 |
Args: |
| 1995 |
origConfig: Original configuration |
| 1996 |
""" |
| 1997 |
(xmlDom, parentNode) = createOutputDom() |
| 1998 |
origConfig.addConfig(xmlDom, parentNode) |
| 1999 |
xmlData = serializeDom(xmlDom) |
| 2000 |
newConfig = LocalConfig(xmlData=xmlData, validate=False) |
| 2001 |
self.assertEqual(origConfig, newConfig) |
| 2002 |
|
| 2003 |
############################ |
| 2004 |
# Test __repr__ and __str__ |
| 2005 |
############################ |
| 2006 |
|
| 2007 |
def testStringFuncs_001(self): |
| 2008 |
""" |
| 2009 |
Just make sure that the string functions don't have errors (i.e. bad variable names). |
| 2010 |
""" |
| 2011 |
obj = LocalConfig() |
| 2012 |
obj.__repr__() |
| 2013 |
obj.__str__() |
| 2014 |
|
| 2015 |
##################################################### |
| 2016 |
# Test basic constructor and attribute functionality |
| 2017 |
##################################################### |
| 2018 |
|
| 2019 |
def testConstructor_001(self): |
| 2020 |
""" |
| 2021 |
Test empty constructor, validate=False. |
| 2022 |
""" |
| 2023 |
config = LocalConfig(validate=False) |
| 2024 |
self.assertEqual(None, config.subversion) |
| 2025 |
|
| 2026 |
def testConstructor_002(self): |
| 2027 |
""" |
| 2028 |
Test empty constructor, validate=True. |
| 2029 |
""" |
| 2030 |
config = LocalConfig(validate=True) |
| 2031 |
self.assertEqual(None, config.subversion) |
| 2032 |
|
| 2033 |
def testConstructor_003(self): |
| 2034 |
""" |
| 2035 |
Test with empty config document as both data and file, validate=False. |
| 2036 |
""" |
| 2037 |
path = self.resources["subversion.conf.1"] |
| 2038 |
with open(path) as f: |
| 2039 |
contents = f.read() |
| 2040 |
self.assertRaises(ValueError, LocalConfig, xmlData=contents, xmlPath=path, validate=False) |
| 2041 |
|
| 2042 |
def testConstructor_004(self): |
| 2043 |
""" |
| 2044 |
Test assignment of subversion attribute, None value. |
| 2045 |
""" |
| 2046 |
config = LocalConfig() |
| 2047 |
config.subversion = None |
| 2048 |
self.assertEqual(None, config.subversion) |
| 2049 |
|
| 2050 |
def testConstructor_005(self): |
| 2051 |
""" |
| 2052 |
Test assignment of subversion attribute, valid value. |
| 2053 |
""" |
| 2054 |
config = LocalConfig() |
| 2055 |
config.subversion = SubversionConfig() |
| 2056 |
self.assertEqual(SubversionConfig(), config.subversion) |
| 2057 |
|
| 2058 |
def testConstructor_006(self): |
| 2059 |
""" |
| 2060 |
Test assignment of subversion attribute, invalid value (not SubversionConfig). |
| 2061 |
""" |
| 2062 |
config = LocalConfig() |
| 2063 |
self.failUnlessAssignRaises(ValueError, config, "subversion", "STRING!") |
| 2064 |
|
| 2065 |
############################ |
| 2066 |
# Test comparison operators |
| 2067 |
############################ |
| 2068 |
|
| 2069 |
def testComparison_001(self): |
| 2070 |
""" |
| 2071 |
Test comparison of two identical objects, all attributes None. |
| 2072 |
""" |
| 2073 |
config1 = LocalConfig() |
| 2074 |
config2 = LocalConfig() |
| 2075 |
self.assertEqual(config1, config2) |
| 2076 |
self.assertTrue(config1 == config2) |
| 2077 |
self.assertTrue(not config1 < config2) |
| 2078 |
self.assertTrue(config1 <= config2) |
| 2079 |
self.assertTrue(not config1 > config2) |
| 2080 |
self.assertTrue(config1 >= config2) |
| 2081 |
self.assertTrue(not config1 != config2) |
| 2082 |
|
| 2083 |
def testComparison_002(self): |
| 2084 |
""" |
| 2085 |
Test comparison of two identical objects, all attributes non-None. |
| 2086 |
""" |
| 2087 |
config1 = LocalConfig() |
| 2088 |
config1.subversion = SubversionConfig() |
| 2089 |
|
| 2090 |
config2 = LocalConfig() |
| 2091 |
config2.subversion = SubversionConfig() |
| 2092 |
|
| 2093 |
self.assertEqual(config1, config2) |
| 2094 |
self.assertTrue(config1 == config2) |
| 2095 |
self.assertTrue(not config1 < config2) |
| 2096 |
self.assertTrue(config1 <= config2) |
| 2097 |
self.assertTrue(not config1 > config2) |
| 2098 |
self.assertTrue(config1 >= config2) |
| 2099 |
self.assertTrue(not config1 != config2) |
| 2100 |
|
| 2101 |
def testComparison_003(self): |
| 2102 |
""" |
| 2103 |
Test comparison of two differing objects, subversion differs (one None). |
| 2104 |
""" |
| 2105 |
config1 = LocalConfig() |
| 2106 |
config2 = LocalConfig() |
| 2107 |
config2.subversion = SubversionConfig() |
| 2108 |
self.assertNotEqual(config1, config2) |
| 2109 |
self.assertTrue(not config1 == config2) |
| 2110 |
self.assertTrue(config1 < config2) |
| 2111 |
self.assertTrue(config1 <= config2) |
| 2112 |
self.assertTrue(not config1 > config2) |
| 2113 |
self.assertTrue(not config1 >= config2) |
| 2114 |
self.assertTrue(config1 != config2) |
| 2115 |
|
| 2116 |
def testComparison_004(self): |
| 2117 |
""" |
| 2118 |
Test comparison of two differing objects, subversion differs. |
| 2119 |
""" |
| 2120 |
config1 = LocalConfig() |
| 2121 |
config1.subversion = SubversionConfig(collectMode="daily") |
| 2122 |
|
| 2123 |
config2 = LocalConfig() |
| 2124 |
config2.subversion = SubversionConfig(collectMode="weekly") |
| 2125 |
|
| 2126 |
self.assertNotEqual(config1, config2) |
| 2127 |
self.assertTrue(not config1 == config2) |
| 2128 |
self.assertTrue(config1 < config2) |
| 2129 |
self.assertTrue(config1 <= config2) |
| 2130 |
self.assertTrue(not config1 > config2) |
| 2131 |
self.assertTrue(not config1 >= config2) |
| 2132 |
self.assertTrue(config1 != config2) |
| 2133 |
|
| 2134 |
###################### |
| 2135 |
# Test validate logic |
| 2136 |
###################### |
| 2137 |
|
| 2138 |
def testValidate_001(self): |
| 2139 |
""" |
| 2140 |
Test validate on a None subversion section. |
| 2141 |
""" |
| 2142 |
config = LocalConfig() |
| 2143 |
config.subversion = None |
| 2144 |
self.assertRaises(ValueError, config.validate) |
| 2145 |
|
| 2146 |
def testValidate_002(self): |
| 2147 |
""" |
| 2148 |
Test validate on an empty subversion section. |
| 2149 |
""" |
| 2150 |
config = LocalConfig() |
| 2151 |
config.subversion = SubversionConfig() |
| 2152 |
self.assertRaises(ValueError, config.validate) |
| 2153 |
|
| 2154 |
def testValidate_003(self): |
| 2155 |
""" |
| 2156 |
Test validate on a non-empty subversion section, repositories=None. |
| 2157 |
""" |
| 2158 |
config = LocalConfig() |
| 2159 |
config.subversion = SubversionConfig("weekly", "gzip", None) |
| 2160 |
self.assertRaises(ValueError, config.validate) |
| 2161 |
|
| 2162 |
def testValidate_004(self): |
| 2163 |
""" |
| 2164 |
Test validate on a non-empty subversion section, repositories=[]. |
| 2165 |
""" |
| 2166 |
config = LocalConfig() |
| 2167 |
config.subversion = SubversionConfig("weekly", "gzip", []) |
| 2168 |
self.assertRaises(ValueError, config.validate) |
| 2169 |
|
| 2170 |
def testValidate_005(self): |
| 2171 |
""" |
| 2172 |
Test validate on a non-empty subversion section, non-empty repositories, |
| 2173 |
defaults set, no values on repositories. |
| 2174 |
""" |
| 2175 |
repositories = [Repository(repositoryPath="/one"), Repository(repositoryPath="/two")] |
| 2176 |
config = LocalConfig() |
| 2177 |
config.subversion = SubversionConfig() |
| 2178 |
config.subversion.collectMode = "daily" |
| 2179 |
config.subversion.compressMode = "gzip" |
| 2180 |
config.subversion.repositories = repositories |
| 2181 |
config.validate() |
| 2182 |
|
| 2183 |
def testValidate_006(self): |
| 2184 |
""" |
| 2185 |
Test validate on a non-empty subversion section, non-empty repositories, |
| 2186 |
no defaults set, no values on repositiories. |
| 2187 |
""" |
| 2188 |
repositories = [Repository(repositoryPath="/one"), Repository(repositoryPath="/two")] |
| 2189 |
config = LocalConfig() |
| 2190 |
config.subversion = SubversionConfig() |
| 2191 |
config.subversion.repositories = repositories |
| 2192 |
self.assertRaises(ValueError, config.validate) |
| 2193 |
|
| 2194 |
def testValidate_007(self): |
| 2195 |
""" |
| 2196 |
Test validate on a non-empty subversion section, non-empty repositories, |
| 2197 |
no defaults set, both values on repositories. |
| 2198 |
""" |
| 2199 |
repositories = [Repository(repositoryPath="/two", collectMode="weekly", compressMode="gzip")] |
| 2200 |
config = LocalConfig() |
| 2201 |
config.subversion = SubversionConfig() |
| 2202 |
config.subversion.repositories = repositories |
| 2203 |
config.validate() |
| 2204 |
|
| 2205 |
def testValidate_008(self): |
| 2206 |
""" |
| 2207 |
Test validate on a non-empty subversion section, non-empty repositories, |
| 2208 |
collectMode only on repositories. |
| 2209 |
""" |
| 2210 |
repositories = [Repository(repositoryPath="/two", collectMode="weekly")] |
| 2211 |
config = LocalConfig() |
| 2212 |
config.subversion = SubversionConfig() |
| 2213 |
config.subversion.compressMode = "gzip" |
| 2214 |
config.subversion.repositories = repositories |
| 2215 |
config.validate() |
| 2216 |
|
| 2217 |
def testValidate_009(self): |
| 2218 |
""" |
| 2219 |
Test validate on a non-empty subversion section, non-empty repositories, |
| 2220 |
compressMode only on repositories. |
| 2221 |
""" |
| 2222 |
repositories = [Repository(repositoryPath="/two", compressMode="bzip2")] |
| 2223 |
config = LocalConfig() |
| 2224 |
config.subversion = SubversionConfig() |
| 2225 |
config.subversion.collectMode = "weekly" |
| 2226 |
config.subversion.repositories = repositories |
| 2227 |
config.validate() |
| 2228 |
|
| 2229 |
def testValidate_010(self): |
| 2230 |
""" |
| 2231 |
Test validate on a non-empty subversion section, non-empty repositories, |
| 2232 |
compressMode default and on repository. |
| 2233 |
""" |
| 2234 |
repositories = [Repository(repositoryPath="/two", compressMode="bzip2")] |
| 2235 |
config = LocalConfig() |
| 2236 |
config.subversion = SubversionConfig() |
| 2237 |
config.subversion.collectMode = "daily" |
| 2238 |
config.subversion.compressMode = "gzip" |
| 2239 |
config.subversion.repositories = repositories |
| 2240 |
config.validate() |
| 2241 |
|
| 2242 |
def testValidate_011(self): |
| 2243 |
""" |
| 2244 |
Test validate on a non-empty subversion section, non-empty repositories, |
| 2245 |
collectMode default and on repository. |
| 2246 |
""" |
| 2247 |
repositories = [Repository(repositoryPath="/two", collectMode="daily")] |
| 2248 |
config = LocalConfig() |
| 2249 |
config.subversion = SubversionConfig() |
| 2250 |
config.subversion.collectMode = "daily" |
| 2251 |
config.subversion.compressMode = "gzip" |
| 2252 |
config.subversion.repositories = repositories |
| 2253 |
config.validate() |
| 2254 |
|
| 2255 |
def testValidate_012(self): |
| 2256 |
""" |
| 2257 |
Test validate on a non-empty subversion section, non-empty repositories, |
| 2258 |
collectMode and compressMode default and on repository. |
| 2259 |
""" |
| 2260 |
repositories = [Repository(repositoryPath="/two", collectMode="daily", compressMode="bzip2")] |
| 2261 |
config = LocalConfig() |
| 2262 |
config.subversion = SubversionConfig() |
| 2263 |
config.subversion.collectMode = "daily" |
| 2264 |
config.subversion.compressMode = "gzip" |
| 2265 |
config.subversion.repositories = repositories |
| 2266 |
config.validate() |
| 2267 |
|
| 2268 |
def testValidate_013(self): |
| 2269 |
""" |
| 2270 |
Test validate on a non-empty subversion section, repositoryDirs=None. |
| 2271 |
""" |
| 2272 |
config = LocalConfig() |
| 2273 |
config.subversion = SubversionConfig("weekly", "gzip", repositoryDirs=None) |
| 2274 |
self.assertRaises(ValueError, config.validate) |
| 2275 |
|
| 2276 |
def testValidate_014(self): |
| 2277 |
""" |
| 2278 |
Test validate on a non-empty subversion section, repositoryDirs=[]. |
| 2279 |
""" |
| 2280 |
config = LocalConfig() |
| 2281 |
config.subversion = SubversionConfig("weekly", "gzip", repositoryDirs=[]) |
| 2282 |
self.assertRaises(ValueError, config.validate) |
| 2283 |
|
| 2284 |
def testValidate_015(self): |
| 2285 |
""" |
| 2286 |
Test validate on a non-empty subversion section, non-empty repositoryDirs, |
| 2287 |
defaults set, no values on repositoryDirs. |
| 2288 |
""" |
| 2289 |
repositoryDirs = [RepositoryDir(directoryPath="/one"), RepositoryDir(directoryPath="/two")] |
| 2290 |
config = LocalConfig() |
| 2291 |
config.subversion = SubversionConfig() |
| 2292 |
config.subversion.collectMode = "daily" |
| 2293 |
config.subversion.compressMode = "gzip" |
| 2294 |
config.subversion.repositoryDirs = repositoryDirs |
| 2295 |
config.validate() |
| 2296 |
|
| 2297 |
def testValidate_016(self): |
| 2298 |
""" |
| 2299 |
Test validate on a non-empty subversion section, non-empty repositoryDirs, |
| 2300 |
no defaults set, no values on repositiories. |
| 2301 |
""" |
| 2302 |
repositoryDirs = [RepositoryDir(directoryPath="/one"), RepositoryDir(directoryPath="/two")] |
| 2303 |
config = LocalConfig() |
| 2304 |
config.subversion = SubversionConfig() |
| 2305 |
config.subversion.repositoryDirs = repositoryDirs |
| 2306 |
self.assertRaises(ValueError, config.validate) |
| 2307 |
|
| 2308 |
def testValidate_017(self): |
| 2309 |
""" |
| 2310 |
Test validate on a non-empty subversion section, non-empty repositoryDirs, |
| 2311 |
no defaults set, both values on repositoryDirs. |
| 2312 |
""" |
| 2313 |
repositoryDirs = [RepositoryDir(directoryPath="/two", collectMode="weekly", compressMode="gzip")] |
| 2314 |
config = LocalConfig() |
| 2315 |
config.subversion = SubversionConfig() |
| 2316 |
config.subversion.repositoryDirs = repositoryDirs |
| 2317 |
config.validate() |
| 2318 |
|
| 2319 |
def testValidate_018(self): |
| 2320 |
""" |
| 2321 |
Test validate on a non-empty subversion section, non-empty repositoryDirs, |
| 2322 |
collectMode only on repositoryDirs. |
| 2323 |
""" |
| 2324 |
repositoryDirs = [RepositoryDir(directoryPath="/two", collectMode="weekly")] |
| 2325 |
config = LocalConfig() |
| 2326 |
config.subversion = SubversionConfig() |
| 2327 |
config.subversion.compressMode = "gzip" |
| 2328 |
config.subversion.repositoryDirs = repositoryDirs |
| 2329 |
config.validate() |
| 2330 |
|
| 2331 |
def testValidate_019(self): |
| 2332 |
""" |
| 2333 |
Test validate on a non-empty subversion section, non-empty repositoryDirs, |
| 2334 |
compressMode only on repositoryDirs. |
| 2335 |
""" |
| 2336 |
repositoryDirs = [RepositoryDir(directoryPath="/two", compressMode="bzip2")] |
| 2337 |
config = LocalConfig() |
| 2338 |
config.subversion = SubversionConfig() |
| 2339 |
config.subversion.collectMode = "weekly" |
| 2340 |
config.subversion.repositoryDirs = repositoryDirs |
| 2341 |
config.validate() |
| 2342 |
|
| 2343 |
def testValidate_020(self): |
| 2344 |
""" |
| 2345 |
Test validate on a non-empty subversion section, non-empty repositoryDirs, |
| 2346 |
compressMode default and on repository. |
| 2347 |
""" |
| 2348 |
repositoryDirs = [RepositoryDir(directoryPath="/two", compressMode="bzip2")] |
| 2349 |
config = LocalConfig() |
| 2350 |
config.subversion = SubversionConfig() |
| 2351 |
config.subversion.collectMode = "daily" |
| 2352 |
config.subversion.compressMode = "gzip" |
| 2353 |
config.subversion.repositoryDirs = repositoryDirs |
| 2354 |
config.validate() |
| 2355 |
|
| 2356 |
def testValidate_021(self): |
| 2357 |
""" |
| 2358 |
Test validate on a non-empty subversion section, non-empty repositoryDirs, |
| 2359 |
collectMode default and on repository. |
| 2360 |
""" |
| 2361 |
repositoryDirs = [RepositoryDir(directoryPath="/two", collectMode="daily")] |
| 2362 |
config = LocalConfig() |
| 2363 |
config.subversion = SubversionConfig() |
| 2364 |
config.subversion.collectMode = "daily" |
| 2365 |
config.subversion.compressMode = "gzip" |
| 2366 |
config.subversion.repositoryDirs = repositoryDirs |
| 2367 |
config.validate() |
| 2368 |
|
| 2369 |
def testValidate_022(self): |
| 2370 |
""" |
| 2371 |
Test validate on a non-empty subversion section, non-empty repositoryDirs, |
| 2372 |
collectMode and compressMode default and on repository. |
| 2373 |
""" |
| 2374 |
repositoryDirs = [RepositoryDir(directoryPath="/two", collectMode="daily", compressMode="bzip2")] |
| 2375 |
config = LocalConfig() |
| 2376 |
config.subversion = SubversionConfig() |
| 2377 |
config.subversion.collectMode = "daily" |
| 2378 |
config.subversion.compressMode = "gzip" |
| 2379 |
config.subversion.repositoryDirs = repositoryDirs |
| 2380 |
config.validate() |
| 2381 |
|
| 2382 |
############################ |
| 2383 |
# Test parsing of documents |
| 2384 |
############################ |
| 2385 |
|
| 2386 |
def testParse_001(self): |
| 2387 |
""" |
| 2388 |
Parse empty config document. |
| 2389 |
""" |
| 2390 |
path = self.resources["subversion.conf.1"] |
| 2391 |
with open(path) as f: |
| 2392 |
contents = f.read() |
| 2393 |
self.assertRaises(ValueError, LocalConfig, xmlPath=path, validate=True) |
| 2394 |
self.assertRaises(ValueError, LocalConfig, xmlData=contents, validate=True) |
| 2395 |
config = LocalConfig(xmlPath=path, validate=False) |
| 2396 |
self.assertEqual(None, config.subversion) |
| 2397 |
config = LocalConfig(xmlData=contents, validate=False) |
| 2398 |
self.assertEqual(None, config.subversion) |
| 2399 |
|
| 2400 |
def testParse_002(self): |
| 2401 |
""" |
| 2402 |
Parse config document with default modes, one repository. |
| 2403 |
""" |
| 2404 |
repositories = [ |
| 2405 |
Repository(repositoryPath="/opt/public/svn/software"), |
| 2406 |
] |
| 2407 |
path = self.resources["subversion.conf.2"] |
| 2408 |
with open(path) as f: |
| 2409 |
contents = f.read() |
| 2410 |
config = LocalConfig(xmlPath=path, validate=False) |
| 2411 |
self.assertNotEqual(None, config.subversion) |
| 2412 |
self.assertEqual("daily", config.subversion.collectMode) |
| 2413 |
self.assertEqual("gzip", config.subversion.compressMode) |
| 2414 |
self.assertEqual(repositories, config.subversion.repositories) |
| 2415 |
self.assertEqual(None, config.subversion.repositoryDirs) |
| 2416 |
config = LocalConfig(xmlData=contents, validate=False) |
| 2417 |
self.assertNotEqual(None, config.subversion) |
| 2418 |
self.assertEqual("daily", config.subversion.collectMode) |
| 2419 |
self.assertEqual("gzip", config.subversion.compressMode) |
| 2420 |
self.assertEqual(repositories, config.subversion.repositories) |
| 2421 |
self.assertEqual(None, config.subversion.repositoryDirs) |
| 2422 |
|
| 2423 |
def testParse_003(self): |
| 2424 |
""" |
| 2425 |
Parse config document with no default modes, one repository |
| 2426 |
""" |
| 2427 |
repositories = [ |
| 2428 |
Repository(repositoryPath="/opt/public/svn/software", collectMode="daily", compressMode="gzip"), |
| 2429 |
] |
| 2430 |
path = self.resources["subversion.conf.3"] |
| 2431 |
with open(path) as f: |
| 2432 |
contents = f.read() |
| 2433 |
config = LocalConfig(xmlPath=path, validate=False) |
| 2434 |
self.assertNotEqual(None, config.subversion) |
| 2435 |
self.assertEqual(None, config.subversion.collectMode) |
| 2436 |
self.assertEqual(None, config.subversion.compressMode) |
| 2437 |
self.assertEqual(repositories, config.subversion.repositories) |
| 2438 |
self.assertEqual(None, config.subversion.repositoryDirs) |
| 2439 |
config = LocalConfig(xmlData=contents, validate=False) |
| 2440 |
self.assertNotEqual(None, config.subversion) |
| 2441 |
self.assertEqual(None, config.subversion.collectMode) |
| 2442 |
self.assertEqual(None, config.subversion.compressMode) |
| 2443 |
self.assertEqual(repositories, config.subversion.repositories) |
| 2444 |
self.assertEqual(None, config.subversion.repositoryDirs) |
| 2445 |
|
| 2446 |
def testParse_004(self): |
| 2447 |
""" |
| 2448 |
Parse config document with default modes, several repositories with |
| 2449 |
various overrides. |
| 2450 |
""" |
| 2451 |
repositories = [] |
| 2452 |
repositories.append(Repository(repositoryPath="/opt/public/svn/one")) |
| 2453 |
repositories.append(Repository(repositoryType="BDB", repositoryPath="/opt/public/svn/two", collectMode="weekly")) |
| 2454 |
repositories.append(Repository(repositoryPath="/opt/public/svn/three", compressMode="bzip2")) |
| 2455 |
repositories.append( |
| 2456 |
Repository(repositoryType="FSFS", repositoryPath="/opt/public/svn/four", collectMode="incr", compressMode="bzip2") |
| 2457 |
) |
| 2458 |
path = self.resources["subversion.conf.4"] |
| 2459 |
with open(path) as f: |
| 2460 |
contents = f.read() |
| 2461 |
config = LocalConfig(xmlPath=path, validate=False) |
| 2462 |
self.assertNotEqual(None, config.subversion) |
| 2463 |
self.assertEqual("daily", config.subversion.collectMode) |
| 2464 |
self.assertEqual("gzip", config.subversion.compressMode) |
| 2465 |
self.assertEqual(repositories, config.subversion.repositories) |
| 2466 |
self.assertEqual(None, config.subversion.repositoryDirs) |
| 2467 |
config = LocalConfig(xmlData=contents, validate=False) |
| 2468 |
self.assertNotEqual(None, config.subversion) |
| 2469 |
self.assertEqual("daily", config.subversion.collectMode) |
| 2470 |
self.assertEqual("gzip", config.subversion.compressMode) |
| 2471 |
self.assertEqual(repositories, config.subversion.repositories) |
| 2472 |
self.assertEqual(None, config.subversion.repositoryDirs) |
| 2473 |
|
| 2474 |
def testParse_005(self): |
| 2475 |
""" |
| 2476 |
Parse config document with default modes, one repository. |
| 2477 |
""" |
| 2478 |
repositoryDirs = [ |
| 2479 |
RepositoryDir(directoryPath="/opt/public/svn/software"), |
| 2480 |
] |
| 2481 |
path = self.resources["subversion.conf.5"] |
| 2482 |
with open(path) as f: |
| 2483 |
contents = f.read() |
| 2484 |
config = LocalConfig(xmlPath=path, validate=False) |
| 2485 |
self.assertNotEqual(None, config.subversion) |
| 2486 |
self.assertEqual("daily", config.subversion.collectMode) |
| 2487 |
self.assertEqual("gzip", config.subversion.compressMode) |
| 2488 |
self.assertEqual(None, config.subversion.repositories) |
| 2489 |
self.assertEqual(repositoryDirs, config.subversion.repositoryDirs) |
| 2490 |
config = LocalConfig(xmlData=contents, validate=False) |
| 2491 |
self.assertNotEqual(None, config.subversion) |
| 2492 |
self.assertEqual("daily", config.subversion.collectMode) |
| 2493 |
self.assertEqual("gzip", config.subversion.compressMode) |
| 2494 |
self.assertEqual(None, config.subversion.repositories) |
| 2495 |
self.assertEqual(repositoryDirs, config.subversion.repositoryDirs) |
| 2496 |
|
| 2497 |
def testParse_006(self): |
| 2498 |
""" |
| 2499 |
Parse config document with no default modes, one repository |
| 2500 |
""" |
| 2501 |
repositoryDirs = [ |
| 2502 |
RepositoryDir(directoryPath="/opt/public/svn/software", collectMode="daily", compressMode="gzip"), |
| 2503 |
] |
| 2504 |
path = self.resources["subversion.conf.6"] |
| 2505 |
with open(path) as f: |
| 2506 |
contents = f.read() |
| 2507 |
config = LocalConfig(xmlPath=path, validate=False) |
| 2508 |
self.assertNotEqual(None, config.subversion) |
| 2509 |
self.assertEqual(None, config.subversion.collectMode) |
| 2510 |
self.assertEqual(None, config.subversion.compressMode) |
| 2511 |
self.assertEqual(None, config.subversion.repositories) |
| 2512 |
self.assertEqual(repositoryDirs, config.subversion.repositoryDirs) |
| 2513 |
config = LocalConfig(xmlData=contents, validate=False) |
| 2514 |
self.assertNotEqual(None, config.subversion) |
| 2515 |
self.assertEqual(None, config.subversion.collectMode) |
| 2516 |
self.assertEqual(None, config.subversion.compressMode) |
| 2517 |
self.assertEqual(None, config.subversion.repositories) |
| 2518 |
self.assertEqual(repositoryDirs, config.subversion.repositoryDirs) |
| 2519 |
|
| 2520 |
def testParse_007(self): |
| 2521 |
""" |
| 2522 |
Parse config document with default modes, several repositoryDirs with |
| 2523 |
various overrides. |
| 2524 |
""" |
| 2525 |
repositoryDirs = [] |
| 2526 |
repositoryDirs.append(RepositoryDir(directoryPath="/opt/public/svn/one")) |
| 2527 |
repositoryDirs.append( |
| 2528 |
RepositoryDir( |
| 2529 |
repositoryType="BDB", directoryPath="/opt/public/svn/two", collectMode="weekly", relativeExcludePaths=["software"] |
| 2530 |
) |
| 2531 |
) |
| 2532 |
repositoryDirs.append( |
| 2533 |
RepositoryDir(directoryPath="/opt/public/svn/three", compressMode="bzip2", excludePatterns=[".*software.*"]) |
| 2534 |
) |
| 2535 |
repositoryDirs.append( |
| 2536 |
RepositoryDir( |
| 2537 |
repositoryType="FSFS", |
| 2538 |
directoryPath="/opt/public/svn/four", |
| 2539 |
collectMode="incr", |
| 2540 |
compressMode="bzip2", |
| 2541 |
relativeExcludePaths=["cedar", "banner"], |
| 2542 |
excludePatterns=[".*software.*", ".*database.*"], |
| 2543 |
) |
| 2544 |
) |
| 2545 |
path = self.resources["subversion.conf.7"] |
| 2546 |
with open(path) as f: |
| 2547 |
contents = f.read() |
| 2548 |
config = LocalConfig(xmlPath=path, validate=False) |
| 2549 |
self.assertNotEqual(None, config.subversion) |
| 2550 |
self.assertEqual("daily", config.subversion.collectMode) |
| 2551 |
self.assertEqual("gzip", config.subversion.compressMode) |
| 2552 |
self.assertEqual(None, config.subversion.repositories) |
| 2553 |
self.assertEqual(repositoryDirs, config.subversion.repositoryDirs) |
| 2554 |
config = LocalConfig(xmlData=contents, validate=False) |
| 2555 |
self.assertNotEqual(None, config.subversion) |
| 2556 |
self.assertEqual("daily", config.subversion.collectMode) |
| 2557 |
self.assertEqual("gzip", config.subversion.compressMode) |
| 2558 |
self.assertEqual(None, config.subversion.repositories) |
| 2559 |
self.assertEqual(repositoryDirs, config.subversion.repositoryDirs) |
| 2560 |
|
| 2561 |
################### |
| 2562 |
# Test addConfig() |
| 2563 |
################### |
| 2564 |
|
| 2565 |
def testAddConfig_001(self): |
| 2566 |
""" |
| 2567 |
Test with empty config document. |
| 2568 |
""" |
| 2569 |
subversion = SubversionConfig() |
| 2570 |
config = LocalConfig() |
| 2571 |
config.subversion = subversion |
| 2572 |
self.validateAddConfig(config) |
| 2573 |
|
| 2574 |
def testAddConfig_002(self): |
| 2575 |
""" |
| 2576 |
Test with defaults set, single repository with no optional values. |
| 2577 |
""" |
| 2578 |
repositories = [] |
| 2579 |
repositories.append(Repository(repositoryPath="/path")) |
| 2580 |
subversion = SubversionConfig(collectMode="daily", compressMode="gzip", repositories=repositories) |
| 2581 |
config = LocalConfig() |
| 2582 |
config.subversion = subversion |
| 2583 |
self.validateAddConfig(config) |
| 2584 |
|
| 2585 |
def testAddConfig_003(self): |
| 2586 |
""" |
| 2587 |
Test with defaults set, single repository with collectMode set. |
| 2588 |
""" |
| 2589 |
repositories = [] |
| 2590 |
repositories.append(Repository(repositoryPath="/path", collectMode="incr")) |
| 2591 |
subversion = SubversionConfig(collectMode="daily", compressMode="gzip", repositories=repositories) |
| 2592 |
config = LocalConfig() |
| 2593 |
config.subversion = subversion |
| 2594 |
self.validateAddConfig(config) |
| 2595 |
|
| 2596 |
def testAddConfig_004(self): |
| 2597 |
""" |
| 2598 |
Test with defaults set, single repository with compressMode set. |
| 2599 |
""" |
| 2600 |
repositories = [] |
| 2601 |
repositories.append(Repository(repositoryPath="/path", compressMode="bzip2")) |
| 2602 |
subversion = SubversionConfig(collectMode="daily", compressMode="gzip", repositories=repositories) |
| 2603 |
config = LocalConfig() |
| 2604 |
config.subversion = subversion |
| 2605 |
self.validateAddConfig(config) |
| 2606 |
|
| 2607 |
def testAddConfig_005(self): |
| 2608 |
""" |
| 2609 |
Test with defaults set, single repository with collectMode and compressMode set. |
| 2610 |
""" |
| 2611 |
repositories = [] |
| 2612 |
repositories.append(Repository(repositoryPath="/path", collectMode="weekly", compressMode="bzip2")) |
| 2613 |
subversion = SubversionConfig(collectMode="daily", compressMode="gzip", repositories=repositories) |
| 2614 |
config = LocalConfig() |
| 2615 |
config.subversion = subversion |
| 2616 |
self.validateAddConfig(config) |
| 2617 |
|
| 2618 |
def testAddConfig_006(self): |
| 2619 |
""" |
| 2620 |
Test with no defaults set, single repository with collectMode and compressMode set. |
| 2621 |
""" |
| 2622 |
repositories = [] |
| 2623 |
repositories.append(Repository(repositoryPath="/path", collectMode="weekly", compressMode="bzip2")) |
| 2624 |
subversion = SubversionConfig(repositories=repositories) |
| 2625 |
config = LocalConfig() |
| 2626 |
config.subversion = subversion |
| 2627 |
self.validateAddConfig(config) |
| 2628 |
|
| 2629 |
def testAddConfig_007(self): |
| 2630 |
""" |
| 2631 |
Test with compressMode set, single repository with collectMode set. |
| 2632 |
""" |
| 2633 |
repositories = [] |
| 2634 |
repositories.append(Repository(repositoryPath="/path", collectMode="weekly")) |
| 2635 |
subversion = SubversionConfig(compressMode="gzip", repositories=repositories) |
| 2636 |
config = LocalConfig() |
| 2637 |
config.subversion = subversion |
| 2638 |
self.validateAddConfig(config) |
| 2639 |
|
| 2640 |
def testAddConfig_008(self): |
| 2641 |
""" |
| 2642 |
Test with collectMode set, single repository with compressMode set. |
| 2643 |
""" |
| 2644 |
repositories = [] |
| 2645 |
repositories.append(Repository(repositoryPath="/path", compressMode="gzip")) |
| 2646 |
subversion = SubversionConfig(collectMode="weekly", repositories=repositories) |
| 2647 |
config = LocalConfig() |
| 2648 |
config.subversion = subversion |
| 2649 |
self.validateAddConfig(config) |
| 2650 |
|
| 2651 |
def testAddConfig_009(self): |
| 2652 |
""" |
| 2653 |
Test with compressMode set, single repository with collectMode and compressMode set. |
| 2654 |
""" |
| 2655 |
repositories = [] |
| 2656 |
repositories.append(Repository(repositoryPath="/path", collectMode="incr", compressMode="gzip")) |
| 2657 |
subversion = SubversionConfig(compressMode="bzip2", repositories=repositories) |
| 2658 |
config = LocalConfig() |
| 2659 |
config.subversion = subversion |
| 2660 |
self.validateAddConfig(config) |
| 2661 |
|
| 2662 |
def testAddConfig_010(self): |
| 2663 |
""" |
| 2664 |
Test with collectMode set, single repository with collectMode and compressMode set. |
| 2665 |
""" |
| 2666 |
repositories = [] |
| 2667 |
repositories.append(Repository(repositoryPath="/path", collectMode="weekly", compressMode="gzip")) |
| 2668 |
subversion = SubversionConfig(collectMode="incr", repositories=repositories) |
| 2669 |
config = LocalConfig() |
| 2670 |
config.subversion = subversion |
| 2671 |
self.validateAddConfig(config) |
| 2672 |
|
| 2673 |
def testAddConfig_011(self): |
| 2674 |
""" |
| 2675 |
Test with defaults set, multiple repositories with collectMode and compressMode set. |
| 2676 |
""" |
| 2677 |
repositories = [] |
| 2678 |
repositories.append(Repository(repositoryPath="/path1", collectMode="daily", compressMode="gzip")) |
| 2679 |
repositories.append(Repository(repositoryPath="/path2", collectMode="weekly", compressMode="gzip")) |
| 2680 |
repositories.append(Repository(repositoryPath="/path3", collectMode="incr", compressMode="gzip")) |
| 2681 |
repositories.append(Repository(repositoryPath="/path1", collectMode="daily", compressMode="bzip2")) |
| 2682 |
repositories.append(Repository(repositoryPath="/path2", collectMode="weekly", compressMode="bzip2")) |
| 2683 |
repositories.append(Repository(repositoryPath="/path3", collectMode="incr", compressMode="bzip2")) |
| 2684 |
subversion = SubversionConfig(collectMode="incr", compressMode="bzip2", repositories=repositories) |
| 2685 |
config = LocalConfig() |
| 2686 |
config.subversion = subversion |
| 2687 |
self.validateAddConfig(config) |