Пример #1
0
 def testConstructor_005(self):
     """
   Test assignment of capacity attribute, valid value.
   """
     config = LocalConfig()
     config.capacity = CapacityConfig()
     self.failUnlessEqual(CapacityConfig(), config.capacity)
Пример #2
0
 def testConstructor_004(self):
     """
   Test assignment of capacity attribute, None value.
   """
     config = LocalConfig()
     config.capacity = None
     self.failUnlessEqual(None, config.capacity)
Пример #3
0
 def testValidate_001(self):
     """
   Test validate on a None capacity section.
   """
     config = LocalConfig()
     config.capacity = None
     self.failUnlessRaises(ValueError, config.validate)
Пример #4
0
 def testValidate_002(self):
     """
   Test validate on an empty capacity section.
   """
     config = LocalConfig()
     config.capacity = CapacityConfig()
     self.failUnlessRaises(ValueError, config.validate)
Пример #5
0
 def testValidate_003(self):
     """
   Test validate on a non-empty capacity section with no values filled in.
   """
     config = LocalConfig()
     config.capacity = CapacityConfig(None, None)
     self.failUnlessRaises(ValueError, config.validate)
Пример #6
0
 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)
Пример #7
0
 def testValidate_005(self):
     """
   Test validate on a non-empty capacity section with only max percentage filled in.
   """
     config = LocalConfig()
     config.capacity = CapacityConfig(
         maxPercentage=PercentageQuantity("63.2"))
     config.validate()
Пример #8
0
 def testAddConfig_001(self):
     """
   Test with empty config document.
   """
     capacity = CapacityConfig()
     config = LocalConfig()
     config.capacity = capacity
     self.validateAddConfig(config)
Пример #9
0
 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)
Пример #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.failUnlessRaises(ValueError, config.validate)
Пример #11
0
 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()
Пример #12
0
 def testAddConfig_002(self):
     """
   Test with max percentage value set.
   """
     capacity = CapacityConfig(
         maxPercentage=PercentageQuantity("63.29128310980123"))
     config = LocalConfig()
     config.capacity = capacity
     self.validateAddConfig(config)
Пример #13
0
 def testComparison_001(self):
     """
   Test comparison of two identical objects, all attributes None.
   """
     config1 = LocalConfig()
     config2 = LocalConfig()
     self.failUnlessEqual(config1, config2)
     self.failUnless(config1 == config2)
     self.failUnless(not config1 < config2)
     self.failUnless(config1 <= config2)
     self.failUnless(not config1 > config2)
     self.failUnless(config1 >= config2)
     self.failUnless(not config1 != config2)
Пример #14
0
 def testComparison_003(self):
     """
   Test comparison of two differing objects, capacity differs (one None).
   """
     config1 = LocalConfig()
     config2 = LocalConfig()
     config2.capacity = CapacityConfig()
     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)
Пример #15
0
 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)
Пример #16
0
 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)
Пример #17
0
 def testParse_002(self):
     """
   Parse config document that configures max percentage.
   """
     path = self.resources["capacity.conf.2"]
     contents = open(path).read()
     config = LocalConfig(xmlPath=path, validate=False)
     self.failIfEqual(None, config.capacity)
     self.failUnlessEqual(PercentageQuantity("63.2"),
                          config.capacity.maxPercentage)
     self.failUnlessEqual(None, config.capacity.minBytes)
     config = LocalConfig(xmlData=contents, validate=False)
     self.failIfEqual(None, config.capacity)
     self.failUnlessEqual(PercentageQuantity("63.2"),
                          config.capacity.maxPercentage)
     self.failUnlessEqual(None, config.capacity.minBytes)
Пример #18
0
 def testParse_001(self):
     """
   Parse empty config document.
   """
     path = self.resources["capacity.conf.1"]
     contents = open(path).read()
     self.failUnlessRaises(ValueError,
                           LocalConfig,
                           xmlPath=path,
                           validate=True)
     self.failUnlessRaises(ValueError,
                           LocalConfig,
                           xmlData=contents,
                           validate=True)
     config = LocalConfig(xmlPath=path, validate=False)
     self.failUnlessEqual(None, config.capacity)
     config = LocalConfig(xmlData=contents, validate=False)
     self.failUnlessEqual(None, config.capacity)
Пример #19
0
 def testStringFuncs_001(self):
     """
   Just make sure that the string functions don't have errors (i.e. bad variable names).
   """
     obj = LocalConfig()
     obj.__repr__()
     obj.__str__()
Пример #20
0
    def validateAddConfig(self, origConfig):
        """
      Validates that document dumped from C{LocalConfig.addConfig} results in
      identical object.

      We dump a document containing just the capacity configuration, and then
      make sure that if we push that document back into the C{LocalConfig}
      object, that the resulting object matches the original.

      The C{self.failUnlessEqual} method is used for the validation, so if the
      method call returns normally, everything is OK.

      @param origConfig: Original configuration.
      """
        (xmlDom, parentNode) = createOutputDom()
        origConfig.addConfig(xmlDom, parentNode)
        xmlData = serializeDom(xmlDom)
        newConfig = LocalConfig(xmlData=xmlData, validate=False)
        self.failUnlessEqual(origConfig, newConfig)
Пример #21
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.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)
Пример #22
0
 def testConstructor_006(self):
     """
   Test assignment of capacity attribute, invalid value (not CapacityConfig).
   """
     config = LocalConfig()
     self.failUnlessAssignRaises(ValueError, config, "capacity", "STRING!")
Пример #23
0
 def testConstructor_002(self):
     """
   Test empty constructor, validate=True.
   """
     config = LocalConfig(validate=True)
     self.failUnlessEqual(None, config.capacity)