def testAddConfig_003(self): """ Test with no databases, all other values filled in, all=True. """ config = LocalConfig() config.mysql = MysqlConfig("user", "password", "none", True, None) self.validateAddConfig(config)
def testAddConfig_004(self): """ Test with no databases, all other values filled in, all=False. """ config = LocalConfig() config.mysql = MysqlConfig("user", "password", "gzip", False, None) self.validateAddConfig(config)
def testValidate_011(self): """ Test validate on a non-empty mysql section, with user=None and password=None. """ config = LocalConfig() config.mysql = MysqlConfig(None, None, "gzip", True, None) config.validate()
def testValidate_007(self): """ Test validate on a non-empty mysql section, all=False, empty databases. """ config = LocalConfig() config.mysql = MysqlConfig("user", "password", "bzip2", False, []) self.failUnlessRaises(ValueError, config.validate)
def testValidate_002(self): """ Test validate on an empty mysql section. """ config = LocalConfig() config.mysql = MysqlConfig() self.failUnlessRaises(ValueError, config.validate)
def testValidate_001(self): """ Test validate on a None mysql section. """ config = LocalConfig() config.mysql = None self.failUnlessRaises(ValueError, config.validate)
def testConstructor_005(self): """ Test assignment of mysql attribute, valid value. """ config = LocalConfig() config.mysql = MysqlConfig() self.failUnlessEqual(MysqlConfig(), config.mysql)
def testParse_006(self): """ Parse config document containing only a mysql section, no user or password, multiple databases, all=False. """ path = self.resources["mysql.conf.5"] contents = open(path).read() config = LocalConfig(xmlPath=path, validate=False) self.failIfEqual(None, config.mysql) self.failUnlessEqual(None, config.mysql.user) self.failUnlessEqual(None, config.mysql.password) self.failUnlessEqual("bzip2", config.mysql.compressMode) self.failUnlessEqual(False, config.mysql.all) self.failUnlessEqual([ "database1", "database2", ], config.mysql.databases) config = LocalConfig(xmlData=contents, validate=False) self.failIfEqual(None, config.mysql) self.failUnlessEqual(None, config.mysql.user) self.failUnlessEqual(None, config.mysql.password) self.failUnlessEqual("bzip2", config.mysql.compressMode) self.failUnlessEqual(False, config.mysql.all) self.failUnlessEqual([ "database1", "database2", ], config.mysql.databases)
def testValidate_004(self): """ Test validate on a non-empty mysql section, all=True, empty databases. """ config = LocalConfig() config.mysql = MysqlConfig("user", "password", "none", True, []) config.validate()
def testValidate_006(self): """ Test validate on a non-empty mysql section, all=False, databases=None. """ config = LocalConfig() config.mysql = MysqlConfig("user", "password", "gzip", False, None) self.failUnlessRaises(ValueError, config.validate)
def testConstructor_004(self): """ Test assignment of mysql attribute, None value. """ config = LocalConfig() config.mysql = None self.failUnlessEqual(None, config.mysql)
def testValidate_003(self): """ Test validate on a non-empty mysql section, all=True, databases=None. """ config = LocalConfig() config.mysql = MysqlConfig("user", "password", "gzip", True, None) config.validate()
def testValidate_008(self): """ Test validate on a non-empty mysql section, all=False, non-empty databases. """ config = LocalConfig() config.mysql = MysqlConfig("user", "password", "gzip", False, [ "whatever", ]) config.validate()
def testAddConfig_006(self): """ Test with single database, all other values filled in, all=False. """ config = LocalConfig() config.mysql = MysqlConfig("user", "password", "none", False, [ "database", ]) self.validateAddConfig(config)
def testAddConfig_011(self): """ Test with multiple databases, user=None and password=None but all other values filled in, all=False. """ config = LocalConfig() config.mysql = MysqlConfig(None, None, "gzip", True, [ "database1", "database2", ]) self.validateAddConfig(config)
def testAddConfig_008(self): """ Test with multiple databases, all other values filled in, all=False. """ config = LocalConfig() config.mysql = MysqlConfig("user", "password", "gzip", True, [ "database1", "database2", ]) 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, mysql differs (one None). """ config1 = LocalConfig() config2 = LocalConfig() config2.mysql = MysqlConfig() 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["mysql.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.mysql) config = LocalConfig(xmlData=contents, validate=False) self.failUnlessEqual(None, config.mysql)
def testParse_003(self): """ Parse config document containing only a mysql section, no databases, all=True. """ path = self.resources["mysql.conf.2"] contents = open(path).read() config = LocalConfig(xmlPath=path, validate=False) self.failIfEqual(None, config.mysql) self.failUnlessEqual("user", config.mysql.user) self.failUnlessEqual("password", config.mysql.password) self.failUnlessEqual("none", config.mysql.compressMode) self.failUnlessEqual(True, config.mysql.all) self.failUnlessEqual(None, config.mysql.databases) config = LocalConfig(xmlData=contents, validate=False) self.failUnlessEqual("user", config.mysql.user) self.failUnlessEqual("password", config.mysql.password) self.failUnlessEqual("none", config.mysql.compressMode) self.failIfEqual(None, config.mysql.password) self.failUnlessEqual(True, config.mysql.all) self.failUnlessEqual(None, config.mysql.databases)
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 validateAddConfig(self, origConfig): """ Validates that document dumped from C{LocalConfig.addConfig} results in identical object. We dump a document containing just the mysql 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 testAddConfig_001(self): """ Test with empty config document """ config = LocalConfig() self.validateAddConfig(config)
def testConstructor_002(self): """ Test empty constructor, validate=True. """ config = LocalConfig(validate=True) self.failUnlessEqual(None, config.mysql)
def testConstructor_006(self): """ Test assignment of mysql attribute, invalid value (not MysqlConfig). """ config = LocalConfig() self.failUnlessAssignRaises(ValueError, config, "mysql", "STRING!")