def testParse_003(self): """ Parse config document with filled-in values. """ path = self.resources["amazons3.conf.3"] with open(path) as f: contents = f.read() config = LocalConfig(xmlPath=path, validate=False) self.assertNotEqual(None, config.amazons3) self.assertEqual(True, config.amazons3.warnMidnite) self.assertEqual("mybucket", config.amazons3.s3Bucket) self.assertEqual("encrypt", config.amazons3.encryptCommand) self.assertEqual(ByteQuantity(2.5, UNIT_GBYTES), config.amazons3.fullBackupSizeLimit) self.assertEqual(ByteQuantity(600, UNIT_MBYTES), config.amazons3.incrementalBackupSizeLimit) config = LocalConfig(xmlData=contents, validate=False) self.assertNotEqual(None, config.amazons3) self.assertEqual(True, config.amazons3.warnMidnite) self.assertEqual("mybucket", config.amazons3.s3Bucket) self.assertEqual("encrypt", config.amazons3.encryptCommand) self.assertEqual(ByteQuantity(2.5, UNIT_GBYTES), config.amazons3.fullBackupSizeLimit) self.assertEqual(ByteQuantity(600, UNIT_MBYTES), config.amazons3.incrementalBackupSizeLimit)
def testConstructor_012f(self): """ Test assignment of fullBackupSizeLimit attribute, valid byte quantity value. """ amazons3 = AmazonS3Config() self.assertEqual(None, amazons3.fullBackupSizeLimit) amazons3.fullBackupSizeLimit = ByteQuantity(600, UNIT_MBYTES) self.assertEqual(ByteQuantity(600, UNIT_MBYTES), amazons3.fullBackupSizeLimit) self.assertEqual(629145600.0, amazons3.fullBackupSizeLimit.bytes)
def testConstructor_015e(self): """ Test assignment of incrementalBackupSizeLimit attribute, valid byte quantity value. """ amazons3 = AmazonS3Config() self.assertEqual(None, amazons3.incrementalBackupSizeLimit) amazons3.incrementalBackupSizeLimit = ByteQuantity(2.5, UNIT_GBYTES) self.assertEqual(ByteQuantity(2.5, UNIT_GBYTES), amazons3.incrementalBackupSizeLimit) self.assertEqual(2684354560.0, amazons3.incrementalBackupSizeLimit.bytes)
def testConstructor_002b(self): """ Test constructor with all values filled in, with valid values (byte quantities). """ amazons3 = AmazonS3Config(True, "bucket", "encrypt", ByteQuantity(1, UNIT_BYTES), ByteQuantity(2, UNIT_BYTES)) self.assertEqual(True, amazons3.warnMidnite) self.assertEqual("bucket", amazons3.s3Bucket) self.assertEqual("encrypt", amazons3.encryptCommand) self.assertEqual(ByteQuantity(1, UNIT_BYTES), amazons3.fullBackupSizeLimit) self.assertEqual(ByteQuantity(2, UNIT_BYTES), amazons3.incrementalBackupSizeLimit)
def testConstructor_015d(self): """ Test assignment of incrementalBackupSizeLimit attribute, valid string value. """ amazons3 = AmazonS3Config() self.assertEqual(None, amazons3.incrementalBackupSizeLimit) amazons3.incrementalBackupSizeLimit = "7516192768" self.assertEqual(7516192768, amazons3.incrementalBackupSizeLimit) self.assertEqual(ByteQuantity("7516192768", UNIT_BYTES), amazons3.incrementalBackupSizeLimit)
def testConstructor_015a(self): """ Test assignment of incrementalBackupSizeLimit attribute, valid int value. """ amazons3 = AmazonS3Config() self.assertEqual(None, amazons3.incrementalBackupSizeLimit) amazons3.incrementalBackupSizeLimit = 15 self.assertEqual(15, amazons3.incrementalBackupSizeLimit) self.assertEqual(ByteQuantity(15, UNIT_BYTES), amazons3.incrementalBackupSizeLimit)
def testConstructor_012c(self): """ Test assignment of fullBackupSizeLimit attribute, valid float value. """ amazons3 = AmazonS3Config() self.assertEqual(None, amazons3.fullBackupSizeLimit) amazons3.fullBackupSizeLimit = 7516192768.0 self.assertEqual(7516192768.0, amazons3.fullBackupSizeLimit) self.assertEqual(ByteQuantity(7516192768.0, UNIT_BYTES), amazons3.fullBackupSizeLimit)
def __cmp__(self, other): """ Original Python 2 comparison operator. Args: other: Other object to compare to Returns: -1/0/1 depending on whether self is ``<``, ``=`` or ``>`` other """ if other is None: return 1 if self.maxPercentage != other.maxPercentage: if (self.maxPercentage or PercentageQuantity()) < (other.maxPercentage or PercentageQuantity()): return -1 else: return 1 if self.minBytes != other.minBytes: if (self.minBytes or ByteQuantity()) < (other.minBytes or ByteQuantity()): return -1 else: return 1 return 0
def __cmp__(self, other): """ Original Python 2 comparison operator. Lists within this class are "unordered" for equality comparisons. Args: other: Other object to compare to Returns: -1/0/1 depending on whether self is ``<``, ``=`` or ``>`` other """ if other is None: return 1 if self.sizeLimit != other.sizeLimit: if (self.sizeLimit or ByteQuantity()) < (other.sizeLimit or ByteQuantity()): return -1 else: return 1 if self.splitSize != other.splitSize: if (self.splitSize or ByteQuantity()) < (other.splitSize or ByteQuantity()): return -1 else: return 1 return 0