Skip to content

Commit

Permalink
Merge pull request #280 from Webperf-se/issue-258
Browse files Browse the repository at this point in the history
solves issue #258
  • Loading branch information
7h3Rabbit authored Mar 3, 2024
2 parents 3173769 + f86347e commit d06fd7a
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions tests/page_not_found.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from urllib.parse import ParseResult, urlunparse
from models import Rating
import datetime
import sys
Expand All @@ -16,6 +17,22 @@
review_show_improvements_only = config.review_show_improvements_only


def change_url_to_404_url(url):

o = urllib.parse.urlparse(url)

path = '{0}/finns-det-en-sida/pa-den-har-adressen/testanrop/'.format(get_guid(5))
if len(o.path) + len(path) < 200:
if o.path.endswith('/'):
path = '{0}{1}'.format(o.path, path)
else:
path = '{0}/{1}'.format(o.path, path)

o2 = ParseResult(scheme=o.scheme, netloc=o.netloc, path=path, params=o.params, query=o.query, fragment=o.fragment)
url2 = urlunparse(o2)
return url2


def run_test(_, langCode, org_url):
"""
Only work on a domain-level. Returns tuple with decimal for grade and string with review
Expand All @@ -34,14 +51,13 @@ def run_test(_, langCode, org_url):
print(_('TEXT_TEST_START').format(
datetime.now().strftime('%Y-%m-%d %H:%M:%S')))

# kollar koden
o = urllib.parse.urlparse(org_url)
url = '{0}://{1}/{3}/{2}'.format(o.scheme, o.netloc,
'finns-det-en-sida/pa-den-har-adressen/testanrop/', get_guid(5))
url = change_url_to_404_url(org_url)

headers = {'user-agent': useragent,
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8'}
code = 'unknown'
request = False
# checks http status code
try:
request = requests.get(url, allow_redirects=True,
headers=headers, timeout=request_timeout)
Expand Down

0 comments on commit d06fd7a

Please sign in to comment.