def test_build_header(self): """Is header created succesfully?""" self.title = "title" empty_sheet = html_builder.HtmlSheet(self.title, None) test_html = empty_sheet.build_header("author") self.assertEqual(test_html[0], test_html_constants.TEST_HEADER) self.assertEqual(test_html[1], "<!-- header -->")
def test_build_columns(self): """Are columns created succesfully?""" self.title = "title" empty_sheet = html_builder.HtmlSheet(self.title, None) test_html = empty_sheet.build_columns(3) self.assertEqual(test_html[0], test_html_constants.TEST_COLUMNS) self.assertEqual(test_html[1], "<!-- columns -->")
def test_set_style(self): """Is color style created succesfully?""" self.title = "title" empty_sheet = html_builder.HtmlSheet(self.title, None) test_html = empty_sheet.set_style(1) self.assertEqual(test_html[0], test_html_constants.TEST_COLOR_STYLE) self.assertEqual(test_html[1], "<!-- css -->")
def test_create_empty_sheet(self): """Is empty sheet html created succesfully?""" self.title = "title" empty_sheet = html_builder.HtmlSheet(self.title, None) test_html = empty_sheet.create_empty_sheet() self.assertEqual(test_html[0], test_html_constants.TEST_EMPTY_SHEET) self.assertEqual(test_html[1], None)
def test_build_text_block(self): """Is text block created succesfully?""" self.title = "test" empty_sheet = html_builder.HtmlSheet(self.title, None) test_html = empty_sheet.build_text_block(2, "block title", "text text text") self.assertEqual(test_html[0], test_html_constants.TEST_TEXT_BLOCK) self.assertEqual(test_html[1], "<!-- column2 -->")
def test_build_rows_block(self): """Is rows block created succesfully?""" self.title = "test" empty_sheet = html_builder.HtmlSheet(self.title, None) test_html = empty_sheet.build_rows_block(1, "block title", 2, ["row1", "row2"]) self.assertEqual(test_html[0], test_html_constants.TEST_ROWS_BLOCK) self.assertEqual(test_html[1], "<!-- column1 -->")
def test_build_footer(self): """Is footer created succesfully?""" self.title = "test" empty_sheet = html_builder.HtmlSheet(self.title, None, "author") test_html = empty_sheet.build_footer("author.png", "http://author.com", "sponsor", "http://sponsor.com") self.assertEqual(test_html[0], test_html_constants.TEST_FOOTER) self.assertEqual(test_html[1], "<!-- footer -->")
def config_sheet(self): """Displays basic sheet styler. Creates a HtmlSheet object instance. Method will ask for HtmlSheet attributes. """ print( "##################################################################" ) print(self.lang_strings["CONFIG_SHEET_MESSAGE1"]) options = { 1: self.lang_strings["CONFIG_SHEET_OPTIONS1"][1], } self.title = self.input_handler(options) print(self.lang_strings["CONFIG_SHEET_MESSAGE2"]) options = { 1: self.lang_strings["CONFIG_SHEET_OPTIONS2"][1], 2: self.lang_strings["CONFIG_SHEET_OPTIONS2"][2], 3: self.lang_strings["CONFIG_SHEET_OPTIONS2"][3], } columns = self.input_handler(options) if columns in ("1", "2", "3"): self.columns = int(columns) else: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) self.config_sheet() print(self.lang_strings["CONFIG_SHEET_MESSAGE3"]) options = { 1: self.lang_strings["CONFIG_SHEET_OPTIONS3"][1], 2: self.lang_strings["CONFIG_SHEET_OPTIONS3"][2], 3: self.lang_strings["CONFIG_SHEET_OPTIONS3"][3], 4: self.lang_strings["CONFIG_SHEET_OPTIONS3"][4], 5: self.lang_strings["CONFIG_SHEET_OPTIONS3"][5], 6: self.lang_strings["CONFIG_SHEET_OPTIONS3"][6], } color = self.input_handler(options) if color in ("1", "2", "3", "4", "5", "6"): color = int(color) else: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) return (self.config_sheet()) self.NewSheet = html_builder.HtmlSheet(self.title, datetime.date.today( )) #Creates a HtmlSheet object with title attrib new_html = self.NewSheet.create_empty_sheet() self.NewSheet.update_html_file(new_html) new_html = self.NewSheet.set_style(color) self.NewSheet.update_html_file(new_html) new_html = self.NewSheet.build_columns(self.columns) self.NewSheet.update_html_file(new_html) self.add_header()