def test_basic(self): result = add_links("word", [TermToAdd("link", "word")]) self.assertEqual("[word](link)", result)
def _add_blocks(head_block, terms): for child in head_block.children: if hasattr(child, 'title'): child.title = add_links(child.title, terms) _add_blocks(child, terms)
def test_english(self): result = add_links("[english](english url)", [TermToAdd("link", "english")]) self.assertEqual("[english](english url)", result)
def test_link_in_text(self): result = add_links("[a 単語 in](link)", [TermToAdd("link", "単語")]) self.assertEqual("[a 単語 in](link)", result)
def test_overlapping_terminology(self): result = add_links( "単語帳 単語", [TermToAdd("link1", "単語"), TermToAdd("link2", "単語帳")]) self.assertEqual("[単語帳](link2) [単語](link1)", result)
def test_multiple_matches(self): result = add_links("単語 単語", [TermToAdd("link", "単語")]) self.assertEqual("[単語](link) [単語](link)", result)
def test_multiple_terms(self): result = add_links( "単語1 単語2", [TermToAdd('link1', '単語1'), TermToAdd('link2', '単語2')]) self.assertEqual("[単語1](link1) [単語2](link2)", result)