def testValidate_002(self): """ Test validate on an empty postgresql section. """ config = LocalConfig() config.postgresql = PostgresqlConfig() self.assertRaises(ValueError, config.validate)
def testValidate_004(self): """ Test validate on a non-empty postgresql section, all=True, empty databases. """ config = LocalConfig() config.postgresql = PostgresqlConfig("user", "none", True, []) config.validate()
def testValidate_001(self): """ Test validate on a None postgresql section. """ config = LocalConfig() config.postgresql = None self.assertRaises(ValueError, config.validate)
def testValidate_007(self): """ Test validate on a non-empty postgresql section, all=False, empty databases. """ config = LocalConfig() config.postgresql = PostgresqlConfig("user", "bzip2", False, []) self.assertRaises(ValueError, config.validate)
def testValidate_006(self): """ Test validate on a non-empty postgresql section, all=False, databases=None. """ config = LocalConfig() config.postgresql = PostgresqlConfig("user", "gzip", False, None) self.assertRaises(ValueError, config.validate)
def testConstructor_004(self): """ Test assignment of postgresql attribute, None value. """ config = LocalConfig() config.postgresql = None self.assertEqual(None, config.postgresql)
def testConstructor_005(self): """ Test assignment of postgresql attribute, valid value. """ config = LocalConfig() config.postgresql = PostgresqlConfig() self.assertEqual(PostgresqlConfig(), config.postgresql)
def testValidate_009(self): """ Test validate on a non-empty postgresql section, with user=None. """ config = LocalConfig() config.postgresql = PostgresqlConfig(None, "gzip", True, None) config.validate()
def testAddConfig_003(self): """ Test with no databases, all other values filled in, all=True. """ config = LocalConfig() config.postgresql = PostgresqlConfig("user", "none", True, None) self.validateAddConfig(config)
def testAddConfig_004(self): """ Test with no databases, all other values filled in, all=False. """ config = LocalConfig() config.postgresql = PostgresqlConfig("user", "gzip", False, None) self.validateAddConfig(config)
def testValidate_003(self): """ Test validate on a non-empty postgresql section, all=True, databases=None. """ config = LocalConfig() config.postgresql = PostgresqlConfig("user", "gzip", True, None) config.validate()
def testAddConfig_009(self): """ Test with multiple databases, user=None but all other values filled in, all=False. """ config = LocalConfig() config.postgresql = PostgresqlConfig(None, "gzip", True, ["database1", "database2"]) self.validateAddConfig(config)
def testAddConfig_005(self): """ Test with single database, all other values filled in, all=True. """ config = LocalConfig() config.postgresql = PostgresqlConfig("user", "bzip2", True, ["database"]) self.validateAddConfig(config)
def testAddConfig_006(self): """ Test with single database, all other values filled in, all=False. """ config = LocalConfig() config.postgresql = PostgresqlConfig("user", "none", False, ["database"]) self.validateAddConfig(config)
def testValidate_008(self): """ Test validate on a non-empty postgresql section, all=False, non-empty databases. """ config = LocalConfig() config.postgresql = PostgresqlConfig("user", "gzip", False, ["whatever"]) config.validate()
def testComparison_001(self): """ Test comparison of two identical objects, all attributes None. """ config1 = LocalConfig() config2 = LocalConfig() self.assertEqual(config1, config2) self.assertTrue(config1 == config2) self.assertTrue(not config1 < config2) self.assertTrue(config1 <= config2) self.assertTrue(not config1 > config2) self.assertTrue(config1 >= config2) self.assertTrue(not config1 != config2)
def testComparison_003(self): """ Test comparison of two differing objects, postgresql differs (one None). """ config1 = LocalConfig() config2 = LocalConfig() config2.postgresql = PostgresqlConfig() 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)
def testParse_001(self): """ Parse empty config document. """ path = self.resources["postgresql.conf.1"] with open(path) as f: contents = f.read() self.assertRaises(ValueError, LocalConfig, xmlPath=path, validate=True) self.assertRaises(ValueError, LocalConfig, xmlData=contents, validate=True) config = LocalConfig(xmlPath=path, validate=False) self.assertEqual(None, config.postgresql) config = LocalConfig(xmlData=contents, validate=False) self.assertEqual(None, config.postgresql)
def testConstructor_006(self): """ Test assignment of postgresql attribute, invalid value (not PostgresqlConfig). """ config = LocalConfig() self.failUnlessAssignRaises(ValueError, config, "postgresql", "STRING!")
def testParse_003(self): """ Parse config document containing only a postgresql section, no databases, all=True. """ path = self.resources["postgresql.conf.2"] with open(path) as f: contents = f.read() config = LocalConfig(xmlPath=path, validate=False) self.assertNotEqual(None, config.postgresql) self.assertEqual("user", config.postgresql.user) self.assertEqual("none", config.postgresql.compressMode) self.assertEqual(True, config.postgresql.all) self.assertEqual(None, config.postgresql.databases) config = LocalConfig(xmlData=contents, validate=False) self.assertEqual("user", config.postgresql.user) self.assertEqual("none", config.postgresql.compressMode) self.assertEqual(True, config.postgresql.all) self.assertEqual(None, config.postgresql.databases)
def testParse_006(self): """ Parse config document containing only a postgresql section, no user, multiple databases, all=False. """ path = self.resources["postgresql.conf.5"] with open(path) as f: contents = f.read() config = LocalConfig(xmlPath=path, validate=False) self.assertNotEqual(None, config.postgresql) self.assertEqual(None, config.postgresql.user) self.assertEqual("bzip2", config.postgresql.compressMode) self.assertEqual(False, config.postgresql.all) self.assertEqual(["database1", "database2"], config.postgresql.databases) config = LocalConfig(xmlData=contents, validate=False) self.assertNotEqual(None, config.postgresql) self.assertEqual(None, config.postgresql.user) self.assertEqual("bzip2", config.postgresql.compressMode) self.assertEqual(False, config.postgresql.all) self.assertEqual(["database1", "database2"], config.postgresql.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 ``LocalConfig.addConfig`` results in identical object. We dump a document containing just the postgresql configuration, and then make sure that if we push that document back into the ``LocalConfig`` object, that the resulting object matches the original. The ``self.failUnlessEqual`` method is used for the validation, so if the method call returns normally, everything is OK. Args: origConfig: Original configuration """ (xmlDom, parentNode) = createOutputDom() origConfig.addConfig(xmlDom, parentNode) xmlData = serializeDom(xmlDom) newConfig = LocalConfig(xmlData=xmlData, validate=False) self.assertEqual(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.assertEqual(None, config.postgresql)