#!/usr/bin/python from cgi import FieldStorage import sys import os root = os.environ("HOME") sys.path.insert(0, root + "/python") from pages.settings import Settings Settings.setRootDirectory(root) from pages.pageloader import PageLoader import cgitb cgitb.enable() print("Content-Type: text/html\n") parms = FieldStorage() paramDict = {} for k in parms.keys(): paramDict[k] = parms.getvalue(k) print(PageLoader().getPage(paramDict))
def testGetNewsDefaultNews(self): Settings.setRootDirectory(".") result = HomePage("").getNews() self.assertTrue(result is not None) print(result)
#!/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 testGetNewsExpiredNewsDir(self): Settings.setRootDirectory("testData/news/expired") result = HomePage("").getNews() self.assertEquals("", result)
def testGetNewsNonEmptyNewsDir(self): Settings.setRootDirectory("testData/news/notexpired") result = HomePage("").getNews() self.assertEquals(1, string.count(result, "<p>"))
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 testUpdateParamsSeasonSpecified(self): params = {"season": "10"} Settings.updateParams(params) Settings.setRootDirectory("/home/sehicl") self.assertEquals("/home/sehicl/data/2009-10.xml", params["xmlFile"])
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 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)