def test_relink_comment(self):
     bc = BlockComment(index=368, regarding=ORIGINAL_TEXT)
     bc.relink_comment(TEXT_START + EXTRA_P + LONG_SENTENCE + TEXT_END,
                       save=False)
     self.assertEqual(579, bc.index)
 def test_text_changes(self):
     bc = BlockComment(index=368, regarding=ORIGINAL_TEXT)
     # Test basic matching tolerance
     self.assertEqual(368, bc.get_match_index(FULL_TEXT))
     self.assertEqual(368, bc.get_match_index(TEXT_START + ONE_CHARACTER + TEXT_END))
     self.assertEqual(368, bc.get_match_index(TEXT_START + ONE_WORD + TEXT_END))
     self.assertEqual(368, bc.get_match_index(TEXT_START + TWO_WORDS + TEXT_END))
     self.assertEqual(368, bc.get_match_index(TEXT_START + ONE_SENTENCE + TEXT_END))
     self.assertEqual(759, bc.get_match_index(TEXT_START + ONE_SENTENCE + ORIGINAL_TEXT + TEXT_END))
     # Expected failure, too similar
     self.assertEqual(-1, bc.get_match_index(TEXT_START + ONE_SENTENCE + ONE_CHARACTER + TEXT_END))
     self.assertEqual(368, bc.get_match_index(TEXT_START + ONE_SENTENCE + LONG_SENTENCE + TEXT_END))
     self.assertEqual(648, bc.get_match_index(TEXT_START + LONG_SENTENCE + ONE_SENTENCE + TEXT_END))
     self.assertEqual(368, bc.get_match_index(TEXT_START + LONG_SENTENCE + TEXT_END))
     # Expected failure, too different
     self.assertEqual(-1, bc.get_match_index(TEXT_START + MULTIPLE_SENTENCES + TEXT_END))
     
     # Test adding blocks in ahead of the match
     self.assertEqual(579, bc.get_match_index(TEXT_START + EXTRA_P + ORIGINAL_TEXT + TEXT_END))
     self.assertEqual(579, bc.get_match_index(TEXT_START + EXTRA_P + ONE_SENTENCE + TEXT_END))
     self.assertEqual(579, bc.get_match_index(TEXT_START + EXTRA_P + LONG_SENTENCE + TEXT_END))
     # Expected failure, too different
     self.assertEqual(-1, bc.get_match_index(TEXT_START + EXTRA_P + MULTIPLE_SENTENCES + TEXT_END))
    def test_text_changes(self):
        bc = BlockComment(index=368, regarding=ORIGINAL_TEXT)
        # Test basic matching tolerance
        self.assertEqual(368, bc.get_match_index(FULL_TEXT))
        self.assertEqual(
            368, bc.get_match_index(TEXT_START + ONE_CHARACTER + TEXT_END))
        self.assertEqual(368,
                         bc.get_match_index(TEXT_START + ONE_WORD + TEXT_END))
        self.assertEqual(368,
                         bc.get_match_index(TEXT_START + TWO_WORDS + TEXT_END))
        self.assertEqual(
            368, bc.get_match_index(TEXT_START + ONE_SENTENCE + TEXT_END))
        self.assertEqual(
            759,
            bc.get_match_index(TEXT_START + ONE_SENTENCE + ORIGINAL_TEXT +
                               TEXT_END))
        # Expected failure, too similar
        self.assertEqual(
            -1,
            bc.get_match_index(TEXT_START + ONE_SENTENCE + ONE_CHARACTER +
                               TEXT_END))
        self.assertEqual(
            368,
            bc.get_match_index(TEXT_START + ONE_SENTENCE + LONG_SENTENCE +
                               TEXT_END))
        self.assertEqual(
            648,
            bc.get_match_index(TEXT_START + LONG_SENTENCE + ONE_SENTENCE +
                               TEXT_END))
        self.assertEqual(
            368, bc.get_match_index(TEXT_START + LONG_SENTENCE + TEXT_END))
        # Expected failure, too different
        self.assertEqual(
            -1, bc.get_match_index(TEXT_START + MULTIPLE_SENTENCES + TEXT_END))

        # Test adding blocks in ahead of the match
        self.assertEqual(
            579,
            bc.get_match_index(TEXT_START + EXTRA_P + ORIGINAL_TEXT +
                               TEXT_END))
        self.assertEqual(
            579,
            bc.get_match_index(TEXT_START + EXTRA_P + ONE_SENTENCE + TEXT_END))
        self.assertEqual(
            579,
            bc.get_match_index(TEXT_START + EXTRA_P + LONG_SENTENCE +
                               TEXT_END))
        # Expected failure, too different
        self.assertEqual(
            -1,
            bc.get_match_index(TEXT_START + EXTRA_P + MULTIPLE_SENTENCES +
                               TEXT_END))
 def test_relink_comment(self):
     bc = BlockComment(index=368, regarding=ORIGINAL_TEXT)
     bc.relink_comment(TEXT_START + EXTRA_P + LONG_SENTENCE + TEXT_END, save=False)
     self.assertEqual(579, bc.index)