From f2bc91e876cc853913aac68a4d412101e65e0812 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Thu, 18 Aug 2022 13:06:32 +0530 Subject: [PATCH] tests: Make functional.is_available check faster Reviewed-by: Sunil Mohan Adapa --- plinth/tests/functional/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index 5a17413af..49f8ddf6e 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -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):