def testAddRepository(self): # addRepository(rep) config = IceConfig(self.context) rep = config.createNewRepository("Name", "Url", "Path", "DocTemplatesPath", "ExportPath") config.addRepository(rep) self.assertEquals(config.getRepNames(), ["Name"])
def testSave(self): config = IceConfig(self.context) saveStr = [None] def saveMethod(xmlStr): saveStr[0] = xmlStr config.save(saveMethod) self.assertEquals(saveStr[0], config.serialize())
def testSerialize(self): expected1 = """<iceConfig version="2.0"> <iceWebHost>localhost</iceWebHost> <iceWebPort>8000</iceWebPort> <iceWebServer>Paste</iceWebServer> <settings /> <repositories /> </iceConfig>""" config = IceConfig(self.context) self.assertEquals(config.serialize(), expected1) config.settings.set("key", "value") e = expected1 e = e.replace("<settings />", '<settings>\n\t\t<var name="key" type="string" value="value" />\n\t</settings>') self.assertEquals(config.serialize(), e)
def testDeleteRepository(self): # deleteRepository(name) config = IceConfig(self.context) config.process(testConfig2XmlStr) self.assertEquals(config.getRepNames(), ["ONE", "TWO"]) config.deleteRepository("ONE") self.assertEquals(config.getRepNames(), ["TWO"])
def testSerialize(self): expected1 = """<iceConfig version="2.0"> <iceWebHost>localhost</iceWebHost> <iceWebPort>8000</iceWebPort> <iceWebServer>Paste</iceWebServer> <settings /> <repositories /> </iceConfig>""" config = IceConfig(self.context) self.assertEquals(config.serialize(), expected1) config.settings.set("key", "value") e = expected1 e = e.replace( "<settings />", '<settings>\n\t\t<var name="key" type="string" value="value" />\n\t</settings>' ) self.assertEquals(config.serialize(), e)
def testProcessAndProperties(self): # Properties: # settings # defaultRepositoryName # port # hostAddress # repositories config = IceConfig(self.context) config.process(testConfig2XmlStr) self.assertEquals(config.settings["testDefault"], "Default") self.assertEquals(config.defaultRepositoryName, "TWO") self.assertEquals(config.port, "8000") self.assertEquals(config.hostAddress, "127.0.0.1") reps = {} for r in config.repositories: reps[r.name] = r #print r.name, r.settings rep1 = reps["ONE"] rep2 = reps["TWO"] self.assertEquals(rep1.settings["testDefault"], "Default") self.assertEquals(rep1.settings.get("test", "not set"), "not set") self.assertEquals(rep2.settings["testDefault"], "OverriddenValue") self.assertEquals(rep2.settings.get("test", "not set"), "Testing")
def setUp(self): class Object(object): pass def getOsHomeDirectory(): return "/home/user/" def readFile(file): return "[file: %s contents]" % file def textToHtml(s): return s self.context = Object() self.context.ElementTree = ElementTree self.context.system = Object() self.context.system.getOsHomeDirectory = getOsHomeDirectory self.context.fs = Object() self.context.fs.readFile = readFile self.context.textToHtml = textToHtml self.context.versionInfoSummary = "ICE version info summary." self.context.config = IceConfig(self.context) self.context.config.process(testConfig2XmlStr)
def testSetDefaultRepositoryName(self): config = IceConfig(self.context) self.assertEquals(config.defaultRepositoryName, None) config.setDefaultRepositoryName("ONE") self.assertEquals(config.defaultRepositoryName, "ONE") self.assertEquals(config.settings["defaultRepositoryName"], "ONE")
def testGetRep(self): # getRep(name) config = IceConfig(self.context) config.process(testConfig2XmlStr) rep = config.getRep("ONE") self.assertEquals(rep.name, "ONE")
def testGetRepNames(self): # getRepNames() config = IceConfig(self.context) config.process(testConfig2XmlStr) self.assertEquals(config.getRepNames(), ["ONE", "TWO"])