from context import (
    SimpleEditTypes,
    StructuredEditTypes,
    curr_html,
    full_diff_to_simple,
    prev_html,
)


def test_basics():
    diff = SimpleEditTypes("html", prev_html, curr_html, lang='en').get_diff()
    expected_changes = {'TF-sup': {'insert': 1}, 'Section': {'change': 1}}
    assert diff == expected_changes

    full_diff = StructuredEditTypes("html", prev_html, curr_html, lang='en').get_diff()
    assert full_diff_to_simple(full_diff) == expected_changes


def test_text_change():
    changed_text = prev_html.replace("popular tourist attraction", "unpopular tourist attraction")
    diff = SimpleEditTypes("html", prev_html, changed_text, lang='en').get_diff()
    expected_changes = {'Word': {'change': 1}, 'Paragraph': {'change': 1}, 'Sentence': {'change': 1}, 'Section': {'change': 1}}
    assert diff == expected_changes

    diff = StructuredEditTypes("html", prev_html, changed_text, lang="en").get_diff()
    assert full_diff_to_simple(diff) == expected_changes
