def testConstructor_008(self): """ Test assignment of minBytes attribute, valid value. """ capacity = CapacityConfig() self.failUnlessEqual(None, capacity.minBytes) capacity.minBytes = ByteQuantity("1.00", UNIT_KBYTES) self.failUnlessEqual(ByteQuantity("1.00", UNIT_KBYTES), capacity.minBytes)
def testConstructor_002(self): """ Test constructor with all values filled in, with valid values. """ capacity = CapacityConfig(PercentageQuantity("63.2"), ByteQuantity("2.0", UNIT_KBYTES)) self.failUnlessEqual(PercentageQuantity("63.2"), capacity.maxPercentage) self.failUnlessEqual(ByteQuantity("2.0", UNIT_KBYTES), capacity.minBytes)
def testComparison_006(self): """ Test comparison of two differing objects, minBytes differs. """ capacity1 = CapacityConfig(PercentageQuantity("63.2"), ByteQuantity("0.5", UNIT_MBYTES)) capacity2 = CapacityConfig(PercentageQuantity("63.2"), ByteQuantity("1.00", UNIT_MBYTES)) self.failIfEqual(capacity1, capacity2) self.failUnless(not capacity1 == capacity2) self.failUnless(capacity1 < capacity2) self.failUnless(capacity1 <= capacity2) self.failUnless(not capacity1 > capacity2) self.failUnless(not capacity1 >= capacity2) self.failUnless(capacity1 != capacity2)
def testComparison_002(self): """ Test comparison of two identical objects, all attributes non-None. """ capacity1 = CapacityConfig(PercentageQuantity("63.2"), ByteQuantity("1.00", UNIT_MBYTES)) capacity2 = CapacityConfig(PercentageQuantity("63.2"), ByteQuantity("1.00", UNIT_MBYTES)) self.failUnlessEqual(capacity1, capacity2) self.failUnless(capacity1 == capacity2) self.failUnless(not capacity1 < capacity2) self.failUnless(capacity1 <= capacity2) self.failUnless(not capacity1 > capacity2) self.failUnless(capacity1 >= capacity2) self.failUnless(not capacity1 != capacity2)
def testParse_004(self): """ Parse config document with filled-in values, size in KB. """ path = self.resources["capacity.conf.4"] contents = open(path).read() config = LocalConfig(xmlPath=path, validate=False) self.failIfEqual(None, config.capacity) self.failUnlessEqual(None, config.capacity.maxPercentage) self.failUnlessEqual(ByteQuantity("1.25", UNIT_KBYTES), config.capacity.minBytes) config = LocalConfig(xmlData=contents, validate=False) self.failIfEqual(None, config.capacity) self.failUnlessEqual(None, config.capacity.maxPercentage) self.failUnlessEqual(ByteQuantity("1.25", UNIT_KBYTES), config.capacity.minBytes)
def testParse_003(self): """ Parse config document that configures min bytes, size in bytes. """ path = self.resources["capacity.conf.3"] contents = open(path).read() config = LocalConfig(xmlPath=path, validate=False) self.failIfEqual(None, config.capacity) self.failUnlessEqual(None, config.capacity.maxPercentage) self.failUnlessEqual(ByteQuantity("18", UNIT_BYTES), config.capacity.minBytes) config = LocalConfig(xmlData=contents, validate=False) self.failIfEqual(None, config.capacity) self.failUnlessEqual(None, config.capacity.maxPercentage) self.failUnlessEqual(ByteQuantity("18", UNIT_BYTES), config.capacity.minBytes)
def testAddConfig_006(self): """ Test with min bytes value set, GB values. """ capacity = CapacityConfig(minBytes=ByteQuantity("63352", UNIT_GBYTES)) config = LocalConfig() config.capacity = capacity self.validateAddConfig(config)
def testAddConfig_003(self): """ Test with min bytes value set, byte values. """ capacity = CapacityConfig(minBytes=ByteQuantity("121231", UNIT_BYTES)) config = LocalConfig() config.capacity = capacity self.validateAddConfig(config)
def testValidate_006(self): """ Test validate on a non-empty capacity section with only min bytes filled in. """ config = LocalConfig() config.capacity = CapacityConfig( minBytes=ByteQuantity("1.00", UNIT_MBYTES)) config.validate()
def testValidate_004(self): """ Test validate on a non-empty capacity section with both max percentage and min bytes filled in. """ config = LocalConfig() config.capacity = CapacityConfig(PercentageQuantity("63.2"), ByteQuantity("1.00", UNIT_MBYTES)) self.failUnlessRaises(ValueError, config.validate)
def testComparison_004(self): """ Test comparison of two differing objects, capacity differs. """ config1 = LocalConfig() config1.capacity = CapacityConfig( minBytes=ByteQuantity("0.1", UNIT_MBYTES)) config2 = LocalConfig() config2.capacity = CapacityConfig( minBytes=ByteQuantity("1.00", UNIT_MBYTES)) self.failIfEqual(config1, config2) self.failUnless(not config1 == config2) self.failUnless(config1 < config2) self.failUnless(config1 <= config2) self.failUnless(not config1 > config2) self.failUnless(not config1 >= config2) self.failUnless(config1 != config2)
def testComparison_005(self): """ Test comparison of two differing objects, minBytes differs (one None). """ capacity1 = CapacityConfig() capacity2 = CapacityConfig(minBytes=ByteQuantity("1.00", UNIT_MBYTES)) self.failIfEqual(capacity1, capacity2) self.failUnless(not capacity1 == capacity2) self.failUnless(capacity1 < capacity2) self.failUnless(capacity1 <= capacity2) self.failUnless(not capacity1 > capacity2) self.failUnless(not capacity1 >= capacity2) self.failUnless(capacity1 != capacity2)