import pytest
from .context import blogger_html_cleaner


class TestTagTools():

    def test_get_pure_tag(self):
        tag1 = '<div>'
        tag2 = '</div>'
        tag3 = '<pre class="prettyprint">'

        assert blogger_html_cleaner.cleaner.get_pure_tag(tag1) == '<div>'
        assert blogger_html_cleaner.cleaner.get_pure_tag(tag2) == '</div>'
        assert blogger_html_cleaner.cleaner.get_pure_tag(tag3) == '<pre>'

    def test_tag_match(self):
        tag1 = '<div>'
        tag2 = '</div>'
        tag3 = '<pre>'
        tag4 = '</pre>'

        assert blogger_html_cleaner.cleaner.tag_match(tag1, tag2) == True
        assert blogger_html_cleaner.cleaner.tag_match(tag1, tag1) == False
        assert blogger_html_cleaner.cleaner.tag_match(tag3, tag2) == False
        assert blogger_html_cleaner.cleaner.tag_match(tag3, tag3) == False
        assert blogger_html_cleaner.cleaner.tag_match(tag3, tag4) == True

class TestUnclosedTagRemover():

    def test_find_next_unclosed(self):
        text = ''

        with open('unclosed') as f:
            text = f.read()

        unclosed = blogger_html_cleaner.cleaner.find_next_unclosed(text)
        assert unclosed == (231, 254)

    def test_remove_unclosed(self):
        text = ''
        expected = ''

        with open('unclosed') as f:
            text = f.read()

        with open('unclosed_expected') as f:
            expected = f.read()

        removed = blogger_html_cleaner.cleaner.remove_unclosed(text)

        assert removed == expected

@@ -51,16 +51,1055 @@
 eaner%0A%0A%0A
+class TestTextManipulation():%0A%0A    def test_replace_regex(self):%0A        string1 = %22This is a%3Cdiv class='remove'%3E test%3Cremove%3E%22%0A        string2 = %22This is a banana%22%0A        string3 = %22%22%22What will happen to this mango, that is on%0A        multiple lines. Will this mango work?%22%22%22%0A%0A        expected1 = %22This is a test%22%0A        expected2 = %22This is a test%22%0A        expected3 = %22%22%22What will happen to this test, that is on%0A        multiple lines. Will this test work?%22%22%22%0A%0A        replaced1 = blogger_html_cleaner.cleaner.replace_regex(r'%3C%5B%5E%3E%5D*%3E', ''%0A                                                              ,string1)%0A        replaced2 = blogger_html_cleaner.cleaner.replace_regex(r'banana'%0A                                                              ,'test', string2)%0A        replaced3 = blogger_html_cleaner.cleaner.replace_regex(r'mango', 'test'%0A                                                              , string3)%0A%0A        assert replaced1 == expected1%0A        assert replaced2 == expected2%0A        assert replaced3 == expected3%0A%0A
 class Te

Add replace_regex() test.