def test_with_wrong_ext(fs):
    src_dir = '/test/sources/'
    fs.create_dir(src_dir)
    fs.create_file(src_dir + "test.hmtl")

    checker = chks.SourceDocsChecker(None, src_dir)

    chunk = Chunk("", "", "", "test.hmtl", 1)
    checker(chunk, None)
    assert not checker.get_errors()
def test_with_dot_and_space_in_the_end(fs):
    src_dir = '/test/sources/'
    fs.create_dir(src_dir)
    fs.create_file(src_dir + "знакомый.ваш.html")

    checker = chks.SourceDocsChecker(None, src_dir)

    chunk = Chunk("", "", "", "знакомый.ваш.html ", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "знакомый.ваш ", 1)
    checker(chunk, None)
    assert not checker.get_errors()
def test_source_docs_checker_basic(fs):
    src_dir = '/test/sources/'
    fs.create_dir(src_dir)
    fs.create_file(src_dir + "1.html")
    fs.create_file(src_dir + "wiki.html")
    fs.create_file(src_dir + "lenovo")
    fs.create_file(src_dir + "я_рюзский.pdf")

    checker = chks.SourceDocsChecker(None, src_dir)
    chunk = Chunk("", "", "", "1", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "1.html", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "wiki.html", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "wiki", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "lenovo", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "lenovo.html", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "я_рюзский.pdf", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "я_рюзский", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "я_рюзский.txt", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "2.html", 1)
    checker(chunk, None)
    assert len(checker.get_errors()) == 1
def create_checkers(opts, sources_dir,
                    spell_checker_whitelist = None):
    return [
        chks.OrigSentChecker(opts),
        chks.SourceDocsChecker(opts, sources_dir),
        chks.PRChecker(opts, fluctuation_delta = 5),
        chks.AddChecker(opts, fluctuation_delta = 5),
        chks.DelChecker(opts, fluctuation_delta = 5),
        chks.CPYChecker(opts, fluctuation_delta = 5),
        chks.CctChecker(opts, fluctuation_delta = 5),
        chks.SspChecker(opts, fluctuation_delta = 5),
        chks.ORIGModTypeChecker(),
        chks.SentCorrectnessChecker(),
        chks.CyrillicAlphabetChecker(opts),
        chks.SpellChecker(whitelist = spell_checker_whitelist)
    ]
def create_checkers(opts, sources_dir, spell_checker_whitelist=None):
    return [
        chks.OriginalityChecker(opts),
        chks.OrigSentChecker(opts),
        chks.ModSentChecker(opts),
        chks.SourceDocsChecker(opts, sources_dir),
        chks.PRChecker(opts),
        # chks.AddChecker(opts),
        # chks.DelChecker(opts),
        # chks.CPYChecker(opts),
        chks.CctChecker(opts),
        # chks.SspChecker(opts),
        chks.SHFChecker(opts),
        # chks.SYNChecker(opts),
        chks.LexicalSimChecker(opts),
        trans_chks.ORIGModTypeChecker(),
        chks.SentCorrectnessChecker(),
        trans_chks.TranslationChecker(opts),
        trans_chks.ManualTranslationChecker(opts),
        chks.CyrillicAlphabetChecker(opts),
        chks.SpellChecker(whitelist=spell_checker_whitelist)
    ]
def test_source_docs_checker_with_whitespace(fs):
    src_dir = '/test/sources/'
    fs.create_dir(src_dir)
    fs.create_file(src_dir + "title kek.html")
    fs.create_file(src_dir + "знакомый ваш.html")
    fs.create_file(src_dir + "kek .html")

    checker = chks.SourceDocsChecker(None, src_dir)

    chunk = Chunk("", "", "", "title kek", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "title kek.html", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "знакомый ваш", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "знакомый ваш", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "знакомый ваш.html", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "kek .html", 1)
    checker(chunk, None)
    assert not checker.get_errors()

    chunk = Chunk("", "", "", "kek ", 1)
    checker(chunk, None)
    assert not checker.get_errors()