def getHtml(self, params={}): html = """ <html> <head> {header} </head> <body id=\"{pageId}\"> {body} </body> </html> """ self.allParams = {} self.allParams.update(self.coreParams) self.allParams.update(params) Settings.updateParams(self.allParams) theHeader = self.getHtmlHeader() thePageId = self.pageId theBody = self.getHtmlBody() answer = Page.stripWhitespace(html.format(header=theHeader, pageId=thePageId, body=theBody)) return answer
#!/usr/bin/python import sys import os from cgi import FieldStorage root = os.getcwd() + "/../.." sys.path.insert(0, root + "/python") from pages.settings import Settings Settings.setRootDirectory(root) html = """ <html> <body> <p>{version}<p> <p>{syspath}<p> <p>{cwd}<p> <p>{params}</p> <p>{dataDir}</p> </body> </html> """ parms = FieldStorage() paramDict = {} for k in parms.keys(): paramDict[k] = parms.getvalue(k) print ("Content-Type: text/html\n") print (html.format(version=sys.version, syspath=sys.path, cwd=os.getcwd(), params=paramDict, dataDir=Settings.dataDirectory))
def testGetNewsDefaultNews(self): Settings.setRootDirectory(".") result = HomePage("").getNews() self.assertTrue(result is not None) print(result)
def testGetNewsNonEmptyNewsDir(self): Settings.setRootDirectory("testData/news/notexpired") result = HomePage("").getNews() self.assertEquals(1, string.count(result, "<p>"))
def testGetNewsExpiredNewsDir(self): Settings.setRootDirectory("testData/news/expired") result = HomePage("").getNews() self.assertEquals("", result)
def testUpdateParamsSeasonSpecified(self): params = {"season": "10"} Settings.updateParams(params) Settings.setRootDirectory("/home/sehicl") self.assertEquals("/home/sehicl/data/2009-10.xml", params["xmlFile"])
def testUpdateParamsNoSeasonSpecified(self): params = {} Settings.defaultSeason = 8 Settings.setRootDirectory("/home/sehicl") Settings.updateParams(params) self.assertEquals("/home/sehicl/data/2007-08.xml", params["xmlFile"])
def testSettingsLoad(self): Settings()
def click_settings_menu_item(self): self.click_options() self.selenium.find_element( *self._settings_menu_item_locator).click() from pages.settings import Settings return Settings(self.base_url, self.selenium)
def click_settings(self): self.selenium.find_element(*self._settings_locator).click() from pages.settings import Settings return Settings(self.testsetup)