def testConstructor_008(self):
     """
     Test assignment of minBytes attribute, valid value.
     """
     capacity = CapacityConfig()
     self.assertEqual(None, capacity.minBytes)
     capacity.minBytes = ByteQuantity("1.00", UNIT_KBYTES)
     self.assertEqual(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.assertEqual(PercentageQuantity("63.2"), capacity.maxPercentage)
     self.assertEqual(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.assertNotEqual(capacity1, capacity2)
     self.assertTrue(not capacity1 == capacity2)
     self.assertTrue(capacity1 < capacity2)
     self.assertTrue(capacity1 <= capacity2)
     self.assertTrue(not capacity1 > capacity2)
     self.assertTrue(not capacity1 >= capacity2)
     self.assertTrue(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.assertEqual(capacity1, capacity2)
     self.assertTrue(capacity1 == capacity2)
     self.assertTrue(not capacity1 < capacity2)
     self.assertTrue(capacity1 <= capacity2)
     self.assertTrue(not capacity1 > capacity2)
     self.assertTrue(capacity1 >= capacity2)
     self.assertTrue(not capacity1 != capacity2)
 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 testParse_004(self):
     """
     Parse config document with filled-in values, size in KB.
     """
     path = self.resources["capacity.conf.4"]
     with open(path) as f:
         contents = f.read()
     config = LocalConfig(xmlPath=path, validate=False)
     self.assertNotEqual(None, config.capacity)
     self.assertEqual(None, config.capacity.maxPercentage)
     self.assertEqual(ByteQuantity("1.25", UNIT_KBYTES),
                      config.capacity.minBytes)
     config = LocalConfig(xmlData=contents, validate=False)
     self.assertNotEqual(None, config.capacity)
     self.assertEqual(None, config.capacity.maxPercentage)
     self.assertEqual(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"]
     with open(path) as f:
         contents = f.read()
     config = LocalConfig(xmlPath=path, validate=False)
     self.assertNotEqual(None, config.capacity)
     self.assertEqual(None, config.capacity.maxPercentage)
     self.assertEqual(ByteQuantity("18", UNIT_BYTES),
                      config.capacity.minBytes)
     config = LocalConfig(xmlData=contents, validate=False)
     self.assertNotEqual(None, config.capacity)
     self.assertEqual(None, config.capacity.maxPercentage)
     self.assertEqual(ByteQuantity("18", UNIT_BYTES),
                      config.capacity.minBytes)
 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()
Beispiel #10
0
 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.assertRaises(ValueError, config.validate)
Beispiel #11
0
    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.assertNotEqual(config1, config2)
        self.assertTrue(not config1 == config2)
        self.assertTrue(config1 < config2)
        self.assertTrue(config1 <= config2)
        self.assertTrue(not config1 > config2)
        self.assertTrue(not config1 >= config2)
        self.assertTrue(config1 != config2)
Beispiel #12
0
 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.assertNotEqual(capacity1, capacity2)
     self.assertTrue(not capacity1 == capacity2)
     self.assertTrue(capacity1 < capacity2)
     self.assertTrue(capacity1 <= capacity2)
     self.assertTrue(not capacity1 > capacity2)
     self.assertTrue(not capacity1 >= capacity2)
     self.assertTrue(capacity1 != capacity2)