Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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()
Example #4
0
 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)
Example #5
0
 def testValidate_002(self):
     """
   Test validate on an empty mysql section.
   """
     config = LocalConfig()
     config.mysql = MysqlConfig()
     self.failUnlessRaises(ValueError, config.validate)
Example #6
0
 def testValidate_001(self):
     """
   Test validate on a None mysql section.
   """
     config = LocalConfig()
     config.mysql = None
     self.failUnlessRaises(ValueError, config.validate)
Example #7
0
 def testConstructor_005(self):
     """
   Test assignment of mysql attribute, valid value.
   """
     config = LocalConfig()
     config.mysql = MysqlConfig()
     self.failUnlessEqual(MysqlConfig(), config.mysql)
Example #8
0
 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)
Example #9
0
 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()
Example #10
0
 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)
Example #11
0
 def testConstructor_004(self):
     """
   Test assignment of mysql attribute, None value.
   """
     config = LocalConfig()
     config.mysql = None
     self.failUnlessEqual(None, config.mysql)
Example #12
0
 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()
Example #13
0
 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()
Example #14
0
 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)
Example #15
0
 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)
Example #16
0
 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)
Example #17
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)
Example #18
0
 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)
Example #19
0
 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)
Example #20
0
 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)
Example #21
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__()
Example #22
0
    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)
Example #23
0
 def testAddConfig_001(self):
     """
   Test with empty config document
   """
     config = LocalConfig()
     self.validateAddConfig(config)
Example #24
0
 def testConstructor_002(self):
     """
   Test empty constructor, validate=True.
   """
     config = LocalConfig(validate=True)
     self.failUnlessEqual(None, config.mysql)
Example #25
0
 def testConstructor_006(self):
     """
   Test assignment of mysql attribute, invalid value (not MysqlConfig).
   """
     config = LocalConfig()
     self.failUnlessAssignRaises(ValueError, config, "mysql", "STRING!")