mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
tests: Make functional.is_available check faster
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
fd3166442f
commit
f2bc91e876
@ -155,18 +155,20 @@ def get_password(username):
|
|||||||
|
|
||||||
|
|
||||||
def is_available(browser, site_name):
|
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)
|
url_to_visit = config['DEFAULT']['url'] + _get_site_url(site_name)
|
||||||
browser.visit(url_to_visit)
|
browser.visit(url_to_visit)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
browser.reload()
|
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,
|
# The site might have a default path after the sitename,
|
||||||
# e.g /mediawiki/Main_Page
|
# e.g /mediawiki/Main_Page
|
||||||
print('URL =', browser.url, url_to_visit, browser.title)
|
print('URL =', browser.url, url_to_visit, browser.title)
|
||||||
browser_url = browser.url.partition('://')[2]
|
browser_url = browser.url.partition('://')[2]
|
||||||
url_to_visit_without_proto = url_to_visit.strip('/').partition('://')[2]
|
url_to_visit_without_proto = url_to_visit.strip('/').partition('://')[2]
|
||||||
no_redirect = browser_url.startswith(url_to_visit_without_proto)
|
return browser_url.startswith(url_to_visit_without_proto) # not a redirect
|
||||||
return not_404 and no_redirect
|
|
||||||
|
|
||||||
|
|
||||||
def download_file(browser, url):
|
def download_file(browser, url):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user