Beispiel #1
0
def test_profanity_many():
    profane_wordcount = 1
    text = " ".join([lorem_text, profane_word])
    word_count = lib.word_count(text)
    profane_percent = (profane_wordcount * 100) / word_count
    too_profane_percent = config['profanity_rater'][
        'safe_profanity_percent'] + config['profanity_rater'][
            'severity_increment_per_percent']
    if profane_percent > too_profane_percent:
        if config['profanity_rater']['severity_start'] < config['severity'][
                'max']:
            assert profanity_severity_rating(
                text, True) > config['profanity_rater']['severity_start']
        else:
            assert profanity_severity_rating(text,
                                             True) == config['severity']['max']

    while profane_percent < too_profane_percent:
        profane_wordcount += 1
        text = " ".join([text, profane_word])
        word_count = lib.word_count(text)
        profane_percent = (profane_wordcount * 100) / word_count

    if config['profanity_rater']['severity_start'] < config['severity']['max']:
        assert profanity_severity_rating(
            text, True) > config['profanity_rater']['severity_start']
    else:
        assert profanity_severity_rating(text,
                                         True) == config['severity']['max']
Beispiel #2
0
def test_keyword_stuffing_many():
    keyword_wordcount = 1
    text = " ".join([lorem_text, keyword])
    word_count = lib.word_count(text)
    keyword_percent = (keyword_wordcount * 100) / word_count
    too_stuffed_percent = config['keyword_stuffing'][
        'safe_keyword_stuffing_percent'] + config['keyword_stuffing'][
            'severity_increment_per_percent']
    if keyword_percent > too_stuffed_percent:
        if config['keyword_stuffing']['severity_start'] < config['severity'][
                'max']:
            assert keyword_stuffing_severity_rating(
                text, keyword,
                True) >= config['keyword_stuffing']['severity_start']
        else:
            assert keyword_stuffing_severity_rating(
                text, keyword, True) == config['severity']['max']

    while keyword_percent < too_stuffed_percent:
        keyword_wordcount += 1
        text = " ".join([text, keyword])
        word_count = lib.word_count(text)
        keyword_percent = (keyword_wordcount * 100) / word_count

    if config['keyword_stuffing']['severity_start'] < config['severity']['max']:
        assert keyword_stuffing_severity_rating(
            text, keyword,
            True) >= config['keyword_stuffing']['severity_start']
    else:
        assert keyword_stuffing_severity_rating(
            text, keyword, True) == config['severity']['max']
Beispiel #3
0
def test_keyword_stuffing_off_some():
    text = " ".join([lorem_text, keyword])
    word_count = lib.word_count(text)
    keyword_percent = (1 * 100) / word_count
    safe_keyword_percent = config['keyword_stuffing'][
        'safe_keyword_stuffing_percent']
    assert keyword_stuffing_severity_rating(text, keyword, True) == 0
Beispiel #4
0
def test_profanity_off_some():
    text = " ".join([lorem_text, profane_word])
    word_count = lib.word_count(text)
    profane_percent = (1 * 100) / word_count
    safe_profanity_percent = config['profanity_rater'][
        'safe_profanity_percent']
    assert profanity_severity_rating(text, False) == 0
Beispiel #5
0
def test_keyword_stuffing_off_many():
    keyword_wordcount = 1
    text = " ".join([lorem_text, keyword])
    word_count = lib.word_count(text)
    keyword_percent = (keyword_wordcount * 100) / word_count
    too_stuffed_percent = config['keyword_stuffing'][
        'safe_keyword_stuffing_percent'] + config['keyword_stuffing'][
            'severity_increment_per_percent']
    if keyword_percent > too_stuffed_percent:
        assert keyword_stuffing_severity_rating(text, keyword, True) == 0

    while keyword_percent < too_stuffed_percent:
        keyword_wordcount += 1
        text = " ".join([text, keyword])
        word_count = lib.word_count(text)
        keyword_percent = (keyword_wordcount * 100) / word_count

    assert keyword_stuffing_severity_rating(text, keyword, False) == 0
Beispiel #6
0
def test_profanity_off_many():
    profane_wordcount = 1
    text = " ".join([lorem_text, profane_word])
    word_count = lib.word_count(text)
    profane_percent = (profane_wordcount * 100) / word_count
    too_profane_percent = config['profanity_rater'][
        'safe_profanity_percent'] + config['profanity_rater'][
            'severity_increment_per_percent']
    if profane_percent > too_profane_percent:
        assert profanity_severity_rating(text, True) == 0

    while profane_percent < too_profane_percent:
        profane_wordcount += 1
        text = " ".join([text, profane_word])
        word_count = lib.word_count(text)
        profane_percent = (profane_wordcount * 100) / word_count

    assert profanity_severity_rating(text, False) == 0
Beispiel #7
0
def test_profanity_some():
    text = " ".join([lorem_text, profane_word])
    word_count = lib.word_count(text)
    profane_percent = (1 * 100) / word_count
    safe_profanity_percent = config['profanity_rater'][
        'safe_profanity_percent']
    if profane_percent > safe_profanity_percent:
        pytest.skip(
            f"Unsupported Configuration: {profane_percent} > {safe_profanity_percent} (config.json)"
        )
    else:
        assert profanity_severity_rating(
            text, True) == config['profanity_rater']['severity_start']
Beispiel #8
0
def test_keyword_stuffing_some():
    text = " ".join([lorem_text, keyword])
    word_count = lib.word_count(text)
    keyword_percent = (1 * 100) / word_count
    safe_keyword_percent = config['keyword_stuffing'][
        'safe_keyword_stuffing_percent']
    if keyword_percent > safe_keyword_percent:
        pytest.skip(f"Tested with another test case.")
    elif keyword_percent < safe_keyword_percent:
        assert keyword_stuffing_severity_rating(text, keyword, True) == 0
    else:
        assert keyword_stuffing_severity_rating(
            text, keyword, True
        ) == config['keyword_stuffing']['safe_keyword_stuffing_percent']