-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: David Venhoff <[email protected]>
- Loading branch information
1 parent
127d22a
commit d83f2ae
Showing
7 changed files
with
215 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
en: Fix the bug invalid links are not replaced | ||
de: Behebe den Fehler, dass ungültige Links nicht ersetzt werden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
from django.contrib.contenttypes.models import ContentType | ||
|
||
from integreat_cms.cms.models import PageTranslation, Region | ||
from integreat_cms.cms.utils.linkcheck_utils import find_target_url_per_content | ||
|
||
REGION: str = "nurnberg" | ||
|
||
# list of tuple (<link types to replace>, <URLs that should be replaced>, <type and id of content that have URLs listed before>) | ||
parameters = [ | ||
( | ||
["invalid"], | ||
["https://tuerantuer.dx/", "https://integreat.app/fake-region/de/willkommen/"], | ||
(PageTranslation, 99), | ||
), | ||
( | ||
["internal"], | ||
[ | ||
"https://integreat.app/fake-region/de/willkommen/", | ||
"https://integreat.app/augsburg/de/willkommen/", | ||
], | ||
(PageTranslation, 99), | ||
), | ||
( | ||
["external"], | ||
["https://tuerantuer.dx/", "https://tuerantuer.de/"], | ||
(PageTranslation, 99), | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.django_db | ||
@pytest.mark.parametrize("parameter", parameters) | ||
def test_find_target_url_per_content_invalid_links( | ||
load_test_data: None, | ||
parameter: tuple[list[str], list[str], tuple[ContentType, int]], | ||
) -> None: | ||
""" | ||
Test link filter per selected link type(s) is working correctly. | ||
""" | ||
link_types, target_urls, target_content_detail = parameter | ||
|
||
# "d" is something many of our links can contain thanks to ".de" or language slug "de" | ||
result = find_target_url_per_content( | ||
"d", "d", Region.objects.filter(slug=REGION).first(), link_types | ||
) | ||
|
||
content_type, content_id = target_content_detail | ||
target_content = content_type.objects.filter(id=content_id).first() | ||
for content, urls in result.items(): | ||
assert content == target_content | ||
assert len(urls) == len(target_urls) | ||
for url in urls: | ||
assert url in target_urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||
<url><loc>https://integreat.app/nurnberg/de/willkommen/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/welcome/"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/الترحيب/"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/fa/خوش-آمدید/"/></url><url><loc>https://integreat.app/nurnberg/de/willkommen/willkommen-in-nurnberg/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/الترحيب/مرحبا-بكم-في-نورنبيرغ/"/></url><url><loc>https://integreat.app/nurnberg/de/willkommen/zusammenleben-in-deutschland/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/welcome/community-life-in-germany/"/></url><url><loc>https://integreat.app/nurnberg/de/willkommen/wissenswertes-uber-nurnberg/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/welcome/trivia-about-nuremberg/"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/الترحيب/معلومات-قيمة-عن-نورنبيرغ/"/></url><url><loc>https://integreat.app/nurnberg/de/willkommen/stadtplan/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority></url><url><loc>https://integreat.app/nurnberg/de/willkommen/uber-integreat/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/welcome/about-integreat/"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/fa/خوش-آمدید/درباره-integreat/"/></url><url><loc>https://integreat.app/nurnberg/de/willkommen/aufenthaltstitel/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority></url><url><loc>https://integreat.app/nurnberg/de/locations/test-ort/</loc><lastmod>2020-01-22</lastmod><changefreq>monthly</changefreq><priority>0.5</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/locations/test-location/"/></url><url><loc>https://integreat.app/nurnberg/de/offers/ihk-lehrstellenboerse</loc><lastmod>2019-10-09</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/offers/ihk-lehrstellenboerse"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/offers/ihk-lehrstellenboerse"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/fa/offers/ihk-lehrstellenboerse"/></url><url><loc>https://integreat.app/nurnberg/de/offers/ihk-praktikumsboerse</loc><lastmod>2019-10-09</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/offers/ihk-praktikumsboerse"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/offers/ihk-praktikumsboerse"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/fa/offers/ihk-praktikumsboerse"/></url><url><loc>https://integreat.app/nurnberg/de/offers/lehrstellen-radar</loc><lastmod>2019-10-09</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/offers/lehrstellen-radar"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/offers/lehrstellen-radar"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/fa/offers/lehrstellen-radar"/></url><url><loc>https://integreat.app/nurnberg/de/events/test-veranstaltung/</loc><lastmod>2020-01-22</lastmod><changefreq>daily</changefreq><priority>0.5</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/events/test-event/"/></url> | ||
<url><loc>https://integreat.app/nurnberg/de/willkommen/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/welcome/"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/الترحيب/"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/fa/خوش-آمدید/"/></url><url><loc>https://integreat.app/nurnberg/de/willkommen/willkommen-in-nurnberg/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/الترحيب/مرحبا-بكم-في-نورنبيرغ/"/></url><url><loc>https://integreat.app/nurnberg/de/willkommen/zusammenleben-in-deutschland/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/welcome/community-life-in-germany/"/></url><url><loc>https://integreat.app/nurnberg/de/willkommen/wissenswertes-uber-nurnberg/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/welcome/trivia-about-nuremberg/"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/الترحيب/معلومات-قيمة-عن-نورنبيرغ/"/></url><url><loc>https://integreat.app/nurnberg/de/willkommen/stadtplan/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority></url><url><loc>https://integreat.app/nurnberg/de/willkommen/uber-integreat/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/welcome/about-integreat/"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/fa/خوش-آمدید/درباره-integreat/"/></url><url><loc>https://integreat.app/nurnberg/de/willkommen/aufenthaltstitel/</loc><lastmod>2019-08-12</lastmod><changefreq>monthly</changefreq><priority>1.0</priority></url><url><loc>https://integreat.app/nurnberg/de/test_links/</loc><lastmod>2022-12-30</lastmod><changefreq>monthly</changefreq><priority>1.0</priority></url><url><loc>https://integreat.app/nurnberg/de/locations/test-ort/</loc><lastmod>2020-01-22</lastmod><changefreq>monthly</changefreq><priority>0.5</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/locations/test-location/"/></url><url><loc>https://integreat.app/nurnberg/de/offers/ihk-lehrstellenboerse</loc><lastmod>2019-10-09</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/offers/ihk-lehrstellenboerse"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/offers/ihk-lehrstellenboerse"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/fa/offers/ihk-lehrstellenboerse"/></url><url><loc>https://integreat.app/nurnberg/de/offers/ihk-praktikumsboerse</loc><lastmod>2019-10-09</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/offers/ihk-praktikumsboerse"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/offers/ihk-praktikumsboerse"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/fa/offers/ihk-praktikumsboerse"/></url><url><loc>https://integreat.app/nurnberg/de/offers/lehrstellen-radar</loc><lastmod>2019-10-09</lastmod><changefreq>monthly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/offers/lehrstellen-radar"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/ar/offers/lehrstellen-radar"/><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/fa/offers/lehrstellen-radar"/></url><url><loc>https://integreat.app/nurnberg/de/events/test-veranstaltung/</loc><lastmod>2020-01-22</lastmod><changefreq>daily</changefreq><priority>0.5</priority><xhtml:link rel="alternate" hreflang="" href="https://integreat.app/nurnberg/en/events/test-event/"/></url> | ||
</urlset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters