def test_get_file_as_string(self): test_file_path = path.join(getcwd(), 'test_html', 'test.html') expected_string = '<html> <body> <h1 class="c-blue text-align-center padding-10">Blow Dry CSS</h1>' \ ' <div class="padding-10 margin-20">Testing<br class="hide" />1 2 3</div> ' \ '</body></html>' file_converter = FileConverter(file_path=test_file_path) self.assertEquals(file_converter.get_file_as_string(), expected_string)
def test_set_attribute_value_list(self): expected_output = ['c-blue text-align-center padding-10', 'padding-10 margin-20', 'hide'] test_file_path = path.join(getcwd(), 'test_html', 'test.html') file_converter = FileConverter(file_path=test_file_path) file_string = file_converter.get_file_as_string() attribute_parser = HTMLAttributeParser(attribute_name='class') attribute_parser.feed(file_string) self.assertEquals(attribute_parser.attribute_value_list, expected_output)
def __init__(self, files): self.class_set = set() for _file in files: # Convert file to string. file_converter = FileConverter(file_path=_file) file_string = file_converter.get_file_as_string() # print(file_string) # Generate list of class strings class_parser = HTMLAttributeParser(attribute_name='class') class_parser.feed(file_string) # Convert list of class strings to set self.__set_class_set(class_parser.attribute_value_list)