def test_raise_exception(self): """An exception should be raised when html_template doesn't exist or when html_template is not a directory. """ confparser = ConfParser() with self.assertRaises(ConfException) as excep: confparser.read_html_template(configuration_file="./test1_conf.txt") with self.assertRaises(ConfException) as excep: confparser.read_html_template(configuration_file="./test2_conf.txt")
def __init__(self): self.htmls = {} try: confparser = ConfParser() self.htmls = confparser.read_html_template() except ConfException as cex: sys.stderr.writelines(cex) # if a customized error file is not provided, use the default one. if "error_page" not in self.htmls or self.htmls["error_page"] is None\ or "" == self.htmls["error_page"]: self.htmls["error_page"] = self.default_error_file
def test_error_file(self): confparser = ConfParser() res = confparser.read_html_template(configuration_file="./test4_conf.txt")["error_file"] self.assertEqual(res, "")
def test_html_template(self): confparser = ConfParser() res = confparser.read_html_template(configuration_file="./test3_conf.txt") self.assertTrue(isinstance(res, dict)) self.assertEqual(res["login_file"], "./html_template/login.html")