tests: Make functional.is_available check faster

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Joseph Nuthalapati 2022-08-18 13:06:32 +05:30 committed by Sunil Mohan Adapa
parent fd3166442f
commit f2bc91e876
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -155,18 +155,20 @@ def get_password(username):
def is_available(browser, site_name):
"""Check if the given site_name is available."""
url_to_visit = config['DEFAULT']['url'] + _get_site_url(site_name)
browser.visit(url_to_visit)
time.sleep(3)
browser.reload()
not_404 = '404' not in browser.title
if '404' in browser.title:
return False
# The site might have a default path after the sitename,
# e.g /mediawiki/Main_Page
print('URL =', browser.url, url_to_visit, browser.title)
browser_url = browser.url.partition('://')[2]
url_to_visit_without_proto = url_to_visit.strip('/').partition('://')[2]
no_redirect = browser_url.startswith(url_to_visit_without_proto)
return not_404 and no_redirect
return browser_url.startswith(url_to_visit_without_proto) # not a redirect
def download_file(browser, url):