def testValidate_003(self): """ Test validate on a non-empty amazons3 section with no values filled in. """ config = LocalConfig() config.amazons3 = AmazonS3Config(None) self.failUnlessRaises(ValueError, config.validate)
def testConstructor_005(self): """ Test assignment of amazons3 attribute, valid value. """ config = LocalConfig() config.amazons3 = AmazonS3Config() self.failUnlessEqual(AmazonS3Config(), config.amazons3)
def testConstructor_004(self): """ Test assignment of amazons3 attribute, None value. """ config = LocalConfig() config.amazons3 = None self.failUnlessEqual(None, config.amazons3)
def testValidate_005(self): """ Test validate on a non-empty amazons3 section with valid values filled in. """ config = LocalConfig() config.amazons3 = AmazonS3Config(True, "bucket") config.validate()
def testValidate_002(self): """ Test validate on an empty amazons3 section. """ config = LocalConfig() config.amazons3 = AmazonS3Config() self.failUnlessRaises(ValueError, config.validate)
def testValidate_001(self): """ Test validate on a None amazons3 section. """ config = LocalConfig() config.amazons3 = None self.failUnlessRaises(ValueError, config.validate)
def testAddConfig_002(self): """ Test with values set. """ amazons3 = AmazonS3Config(True, "bucket", "encrypt", 1, 2) config = LocalConfig() config.amazons3 = amazons3 self.validateAddConfig(config)
def testAddConfig_001(self): """ Test with empty config document. """ amazons3 = AmazonS3Config() config = LocalConfig() config.amazons3 = amazons3 self.validateAddConfig(config)
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)
def testComparison_003(self): """ Test comparison of two differing objects, amazons3 differs (one None). """ config1 = LocalConfig() config2 = LocalConfig() config2.amazons3 = AmazonS3Config() 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 testParse_001(self): """ Parse empty config document. """ path = self.resources["amazons3.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.amazons3) config = LocalConfig(xmlData=contents, validate=False) self.failUnlessEqual(None, config.amazons3)
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__()
def testParse_002(self): """ Parse config document with filled-in values. """ path = self.resources["amazons3.conf.2"] contents = open(path).read() config = LocalConfig(xmlPath=path, validate=False) self.failIfEqual(None, config.amazons3) self.failUnlessEqual(True, config.amazons3.warnMidnite) self.failUnlessEqual("mybucket", config.amazons3.s3Bucket) self.failUnlessEqual("encrypt", config.amazons3.encryptCommand) self.failUnlessEqual(5368709120L, config.amazons3.fullBackupSizeLimit) self.failUnlessEqual(2147483648, config.amazons3.incrementalBackupSizeLimit) config = LocalConfig(xmlData=contents, validate=False) self.failIfEqual(None, config.amazons3) self.failUnlessEqual(True, config.amazons3.warnMidnite) self.failUnlessEqual("mybucket", config.amazons3.s3Bucket) self.failUnlessEqual("encrypt", config.amazons3.encryptCommand) self.failUnlessEqual(5368709120L, config.amazons3.fullBackupSizeLimit) self.failUnlessEqual(2147483648, config.amazons3.incrementalBackupSizeLimit)
def testParse_003(self): """ Parse config document with filled-in values. """ path = self.resources["amazons3.conf.3"] contents = open(path).read() config = LocalConfig(xmlPath=path, validate=False) self.failIfEqual(None, config.amazons3) self.failUnlessEqual(True, config.amazons3.warnMidnite) self.failUnlessEqual("mybucket", config.amazons3.s3Bucket) self.failUnlessEqual("encrypt", config.amazons3.encryptCommand) self.failUnlessEqual(ByteQuantity(2.5, UNIT_GBYTES), config.amazons3.fullBackupSizeLimit) self.failUnlessEqual(ByteQuantity(600, UNIT_MBYTES), config.amazons3.incrementalBackupSizeLimit) config = LocalConfig(xmlData=contents, validate=False) self.failIfEqual(None, config.amazons3) self.failUnlessEqual(True, config.amazons3.warnMidnite) self.failUnlessEqual("mybucket", config.amazons3.s3Bucket) self.failUnlessEqual("encrypt", config.amazons3.encryptCommand) self.failUnlessEqual(ByteQuantity(2.5, UNIT_GBYTES), config.amazons3.fullBackupSizeLimit) self.failUnlessEqual(ByteQuantity(600, UNIT_MBYTES), config.amazons3.incrementalBackupSizeLimit)
def validateAddConfig(self, origConfig): """ Validates that document dumped from C{LocalConfig.addConfig} results in identical object. We dump a document containing just the amazons3 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)
def testComparison_004(self): """ Test comparison of two differing objects, s3Bucket differs. """ config1 = LocalConfig() config1.amazons3 = AmazonS3Config(True, "bucket1", "encrypt", 1, 2) config2 = LocalConfig() config2.amazons3 = AmazonS3Config(True, "bucket2", "encrypt", 1, 2) 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 testConstructor_001(self): """ Test empty constructor, validate=False. """ config = LocalConfig(validate=False) self.failUnlessEqual(None, config.amazons3)
def testConstructor_006(self): """ Test assignment of amazons3 attribute, invalid value (not AmazonS3Config). """ config = LocalConfig() self.failUnlessAssignRaises(ValueError, config, "amazons3", "STRING!")