def test_title_containing_formatting(self): """Test that title is correct when there was already formatting marks (internal formatting shall be removed) """ test_str = "test " + Color.BOLD + "bold" + Color.END + " str" formatted_str = PrintFormatter.title(test_str) self.assertEqual(formatted_str, "\n\033[1mTEST BOLD STR\033[0m\n")
def test_title_is_bold(self): """Test that the result format is surrounded by bold commands""" test_str = "test str" formatted_str = PrintFormatter.title(test_str) str_length = len(formatted_str) self.assertTrue(str_length > 8) self.assertEqual(formatted_str.find('\033[1m'), 1) self.assertEqual(formatted_str.find('\033[0m'), str_length - 5)
def test_title_line_breaks(self): """Test that the result begins and ends with a line break""" test_str = "test str" formatted_str = PrintFormatter.title(test_str) str_length = len(formatted_str) self.assertTrue(str_length > 2) self.assertEqual(formatted_str[0], '\n') self.assertEqual(formatted_str[str_length - 1], '\n')
def get_help(self): """Return the detailed help about the "help" command options and usage.""" return ( PF.title("Help command manual") + PF.section("Description") + PF.paragraph(self.description) + PF.section("Synopsis") + PF.paragraph(Color.BOLD + "./orchid help [COMMAND]" + Color.END) + PF.section("Description") + PF.paragraph( "With no " + Color.BOLD + "COMMAND" + Color.END + " specified, print available commands on the standard output.") + PF.paragraph( "If " + Color.BOLD + "COMMAND" + Color.END + " is specified and exists, print the help manual of the command on the standard output." ))
def test_title_removes_inner_line_breaks(self): """Test that inner line breaks are removed""" test_str = "test\nbroken\nstr" formatted_str = PrintFormatter.title(test_str) str_length = len(formatted_str) self.assertEqual(formatted_str, "\n\033[1mTEST BROKEN STR\033[0m\n")
def test_title_empty_string(self): """Test that the result is an empty string for an empty string""" test_str = "" formatted_str = PrintFormatter.title(test_str) self.assertEqual(formatted_str, "")
def test_title_is_upper(self): """Test that the content to format is kept as upper case""" test_str = "test str" formatted_str = PrintFormatter.title(test_str) self.assertEqual(formatted_str.count(test_str.upper()), 1)