Beispiel #1
0
def test_keyword_present_first_paragraph_kws():
    from django_check_seo.checks_list import check_keywords
    from django_check_seo.checks_list import keyword_present_first_paragraph

    site = init()
    site.soup.find(
        "p"
    ).string = "There are two kw inside the first paragraph: title and description."
    site.content_text = get_content_text(site.soup.find_all("body"))

    check_keywords.run(site)
    keyword_present_first_paragraph.run(site)

    for success in site.success:
        if success.name == "Keywords found in first paragraph":
            assert success.name == "Keywords found in first paragraph"
            assert success.settings == "before 50 words"
            assert success.found == "description, title"
            assert success.searched_in == [
                'there are two kw inside the first paragraph: <b class="good">title</b> and <b class="good">description</b>.'
            ]
            assert (
                success.description ==
                "The reader will be relieved to find one of his keywords in the first paragraph of your page, and the same logic applies to Google, which will consider the content more relevant."
            )
Beispiel #2
0
def test_h2_2_kw():
    import copy
    from django_check_seo.checks_list import check_h2
    from django_check_seo.checks_list import check_keywords

    site = init()

    check_keywords.run(site)
    site.soup.find("h2").string = "Title of the page"
    site.soup.body.append(copy.copy(site.soup.find("h2")))

    check_h2.run(site)

    for success in site.success:
        if success.name == "Keyword found in h2 tags":
            assert success.name == "Keyword found in h2 tags"
            assert success.settings == "at least one"
            assert success.found == "title, title"
            assert success.searched_in == [
                '<b class="good">title</b> of the page',
                '<b class="good">title</b> of the page',
            ]
            assert (
                success.description ==
                "Google uses h2 tags to better understand the subjects of your page."
            )
def test_keyword_url_nokw():
    from django_check_seo.checks_list import check_keyword_url
    from django_check_seo.checks_list import check_keywords

    site = init()
    check_keywords.run(site)
    site.full_url = "https://localhost/fake-url/notitle-of-the-page"
    check_keyword_url.run(site)

    for problem in site.problems:
        if problem.name == "No keyword in URL":
            assert problem.name == "No keyword in URL"
            assert problem.settings == "at least one"
            assert problem.found == "none"
            assert problem.searched_in == [
                "https://localhost/fake-url/notitle-of-the-page"
            ]
Beispiel #4
0
def test_keyword_kw():
    from django_check_seo.checks_list import check_keywords

    site = init()

    check_keywords.run(site)

    for success in site.success:
        if success.name == "Keywords found in meta keywords field":
            assert success.name == "Keywords found in meta keywords field"
            assert success.settings == "at least one"
            assert success.found == 2
            assert success.searched_in == ["description", "title"]
            assert (
                success.description ==
                "Django-check-seo uses the keywords in the meta keywords field to check all other tests related to the keywords. A series of problems and warnings are related to keywords, and will therefore systematically be activated if the keywords are not filled in."
            )
Beispiel #5
0
def test_title_kws():
    from django_check_seo.checks_list import check_title
    from django_check_seo.checks_list import check_keywords

    site = init()
    check_keywords.run(site)

    site.soup.find("title").string = "This title have a description."
    check_title.run(site)

    for success in site.success:
        if success.name == "Keywords found in meta title tag":
            assert success.name == "Keywords found in meta title tag"
            assert success.settings == "at least one"
            assert success.found == "description, title"
            assert success.searched_in == [
                'this <b class="good">title</b> have a <b class="good">description</b>.'
            ]
def test_keyword_url_nokw_root():
    from django_check_seo.checks_list import check_keyword_url
    from django_check_seo.checks_list import check_keywords

    site = init()
    check_keywords.run(site)
    site.full_url = "https://localhost/"
    check_keyword_url.run(site)

    for success in site.success:
        if success.name == "Keywords found in URL":
            raise ValueError("We don't espect kw to be found in root URL")

    for problem in site.problems:
        if problem.name == "No keyword in URL":
            raise ValueError(
                "We shouldnt return a problem if a keyword is not found in root URL"
            )
Beispiel #7
0
def test_keyword_nokw():
    from django_check_seo.checks_list import check_keywords

    site = init()
    site.soup.select('meta[name="keywords"]')[0]["content"] = ""

    check_keywords.run(site)

    for problem in site.problems:
        if problem.name == "No keywords in meta keywords field":
            assert problem.name == "No keywords in meta keywords field"
            assert problem.settings == "at least one"
            assert problem.found == "none"
            assert problem.searched_in == []
            assert (
                problem.description ==
                "Django-check-seo uses the keywords in the meta keywords field to check all other tests related to the keywords. A series of problems and warnings are related to keywords, and will therefore systematically be activated if the keywords are not filled in."
            )
Beispiel #8
0
def test_keyword_present_first_paragraph_nokw():
    from django_check_seo.checks_list import check_keywords
    from django_check_seo.checks_list import keyword_present_first_paragraph

    site = init()
    site.soup.find("p").string = "There is no keyword inside first 50 words."
    site.content_text = get_content_text(site.soup.find_all("body"))

    check_keywords.run(site)
    keyword_present_first_paragraph.run(site)

    for problem in site.problems:
        if problem.name == "No keyword in first paragraph":
            assert problem.name == "No keyword in first paragraph"
            assert problem.settings == "before 50 words"
            assert problem.found == "none"
            assert problem.searched_in == [
                "there is no keyword inside first 50 words."
            ]
Beispiel #9
0
def test_title_kw():
    from django_check_seo.checks_list import check_title
    from django_check_seo.checks_list import check_keywords

    site = init()
    check_keywords.run(site)

    check_title.run(site)

    for success in site.success:
        if success.name == "Keywords found in meta title tag":
            assert success.name == "Keywords found in meta title tag"
            assert success.settings == "at least one"
            assert success.found == "title"
            assert success.searched_in == ['<b class="good">title</b> of the page']
            assert (
                success.description
                == "Meta titles tags need to contain at least one keyword, since they are one of the most important content of the page for search engines."
            )
Beispiel #10
0
def test_h1_1_kw_strange1():
    from django_check_seo.checks_list import check_h1
    from django_check_seo.checks_list import check_keywords

    site = init()
    site.soup.select('meta[name="keywords"]')[0]["content"] = "@letics"

    site.soup.find("h1").string = "word @letics another-word"

    check_keywords.run(site)

    check_h1.run(site)

    for success in site.success:
        if success.name == "Keyword found in h1":
            assert success.found == "@letics"
            assert success.searched_in == [
                'word <b class="good">@letics</b> another-word'
            ]
Beispiel #11
0
def test_h2_1_kws():
    from django_check_seo.checks_list import check_h2
    from django_check_seo.checks_list import check_keywords

    site = init()

    check_keywords.run(site)
    site.soup.find("h2").string = "Title of the page description"

    check_h2.run(site)

    for success in site.success:
        if success.name == "Keyword found in h2 tags":
            assert success.name == "Keyword found in h2 tags"
            assert success.settings == "at least one"
            assert success.found == "description, title"
            assert success.searched_in == [
                '<b class="good">title</b> of the page <b class="good">description</b>'
            ]
def test_description_1_kws():
    from django_check_seo.checks_list import check_keywords
    from django_check_seo.checks_list import check_description

    site = init()

    site.soup.select('meta[name="description"]')[0][
        "content"] = "Here is the description of the page without title."

    check_keywords.run(site)
    check_description.run(site)

    for success in site.success:
        if success.name == "Keywords were found in meta description":
            assert success.settings == "at least one"
            assert success.found == "description, title"
            assert success.searched_in == [
                'here is the <b class="good">description</b> of the page without <b class="good">title</b>.'
            ]
Beispiel #13
0
def test_keyword_present_first_paragraph_kw():
    from django_check_seo.checks_list import check_keywords
    from django_check_seo.checks_list import keyword_present_first_paragraph

    site = init()
    check_keywords.run(site)
    keyword_present_first_paragraph.run(site)

    for success in site.success:
        if success.name == "Keywords found in first paragraph":
            assert success.name == "Keywords found in first paragraph"
            assert success.settings == "before 50 words"
            assert success.found == "title"
            assert success.searched_in == [
                'lorem ipsum dolor sit amet, consectetur adipiscing elit. morbi pharetra metus ut tellus interdum consectetur. in vehicula orci vel fermentum pretium. vestibulum ante ipsum primis in faucibus orci <b class="good">title</b> luctus et ultrices posuere cubilia curae; cras consequat nunc arcu, ut tristique nulla molestie vel. morbi vitae diam nibh. proin ex'
            ]
            assert (
                success.description ==
                "The reader will be relieved to find one of his keywords in the first paragraph of your page, and the same logic applies to Google, which will consider the content more relevant."
            )
def test_keyword_url_kws():
    from django_check_seo.checks_list import check_keyword_url
    from django_check_seo.checks_list import check_keywords

    site = init()
    site.soup.select('meta[name="keywords"]')[0]["content"] = "title,  page"

    check_keywords.run(site)
    site.full_url = "https://localhost/fake-url/title-of-the-page"

    check_keyword_url.run(site)

    for success in site.success:
        if success.name == "Keywords found in URL":
            assert success.name == "Keywords found in URL"
            assert success.settings == "at least one"
            assert success.found == "title, page"
            assert success.searched_in == [
                'https://localhost/fake-url/<b class="good">title</b>-of-the-<b class="good">page</b>'
            ]
Beispiel #15
0
def test_title_nokw():
    from django_check_seo.checks_list import check_title
    from django_check_seo.checks_list import check_keywords

    site = init()
    check_keywords.run(site)

    site.soup.find("title").string = "There is notitle on this page."
    check_title.run(site)

    for problem in site.problems:
        if problem.name == "Meta title tag do not contain any keyword":
            assert problem.name == "Meta title tag do not contain any keyword"
            assert problem.settings == "at least one"
            assert problem.found == "none"
            assert problem.searched_in == ["there is notitle on this page."]
            assert (
                problem.description
                == "Meta titles tags need to contain at least one keyword, since they are one of the most important content of the page for search engines."
            )
def test_keyword_url_kw():
    from django_check_seo.checks_list import check_keyword_url
    from django_check_seo.checks_list import check_keywords

    site = init()

    check_keywords.run(site)
    check_keyword_url.run(site)

    for success in site.success:
        if success.name == "Keywords found in URL":
            assert success.name == "Keywords found in URL"
            assert success.settings == "at least one"
            assert success.found == "title"
            assert success.searched_in == [
                'https://localhost/fake-url/<b class="good">title</b>-of-the-page/'
            ]
            assert (
                success.description ==
                'Keywords in URL will help your users understand the organisation of your website, and are a small ranking factor for Google. On the other hand, Bing guidelines advises to "<i>keep [your URL] clean and keyword rich when possible</i>".'
            )
Beispiel #17
0
def test_h1_1_kw():
    from django_check_seo.checks_list import check_h1
    from django_check_seo.checks_list import check_keywords

    site = init()

    check_keywords.run(site)

    check_h1.run(site)

    for success in site.success:
        if success.name == "Keyword found in h1":
            assert success.name == "Keyword found in h1"
            assert success.settings == "at least one"
            assert success.found == "title"
            assert success.searched_in == [
                '<b class="good">title</b> of the page'
            ]
            assert (
                success.description ==
                "The h1 tag represent the main title of your page, and you may populate it with appropriate content in order to ensure that users (and search engines!) will understand correctly your page."
            )