Backups: functional tests update; restoring backup bugfix

- updated functional tests to work with changed UI
- fixed bug when restoring an uploaded file

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Michael Pimmer authored and James Valleroy committed 2018-12-13 18:28:31 -05:00
1 parent 3724dac9e6
commit 067fea7d17
5 files changed
+23 -15

No files matched your search

+2 -2
View File
@@ -67,6 +67,6 @@ Scenario: Download, upload and restore a backup
When I set bind forwarders to 1.1.1.1
And I create a backup of the bind app data
And I set bind forwarders to 1.0.0.1
And I download the bind app data backup
And I restore the downloaded bind app data backup
And I download the latest app data backup
And I restore the downloaded app data backup
Then bind forwarders should be 1.1.1.1
+4 -7
View File
@@ -183,12 +183,9 @@ def backup_create(browser, app_name):
system.backup_create(browser, app_name)
@when(parsers.parse('I download the {app_name:w} app data backup'))
def backup_download(browser, app_name, downloaded_file_info):
url = '/plinth/sys/backups/download/root/_functional_test_%s/' % \
app_name
file_path = system.download_file_logged_in(browser, url, app_name,
suffix='.tar.gz')
@when(parsers.parse('I download the latest app data backup'))
def backup_download(browser, downloaded_file_info):
file_path = system.download_latest_backup(browser)
downloaded_file_info['path'] = file_path
@@ -197,7 +194,7 @@ def backup_restore(browser, app_name):
system.backup_restore(browser, app_name)
@when(parsers.parse('I restore the downloaded {app_name:w} app data backup'))
@when(parsers.parse('I restore the downloaded app data backup'))
def backup_restore_from_upload(browser, app_name, downloaded_file_info):
path = downloaded_file_info["path"]
try:
+13 -4
View File
@@ -203,7 +203,6 @@ def backup_create(browser, app_name):
application.install(browser, 'backups')
browser.find_link_by_href('/plinth/sys/backups/create/').first.click()
browser.find_by_id('id_backups-name').fill('_functional_test_' + app_name)
for app in browser.find_by_css('input[type=checkbox]'):
app.uncheck()
@@ -236,10 +235,20 @@ def backup_upload_and_restore(browser, app_name, downloaded_file_path):
submit(browser)
def download_file_logged_in(browser, url_path, app_names, suffix=''):
def download_latest_backup(browser):
nav_to_module(browser, 'backups')
path = "//a[starts-with(@href,'/plinth/sys/backups/download/root')]"
ele = browser.driver.find_elements_by_xpath(path)[0]
url = ele.get_attribute('href')
file_path = download_file_logged_in(browser, url, suffix='.tar.gz')
return file_path
def download_file_logged_in(browser, url, suffix=''):
"""Download a file from Plinth, pretend being logged in via cookies"""
current_url = urlparse(browser.url)
url = "%s://%s%s" % (current_url.scheme, current_url.netloc, url_path)
if not url.startswith("http"):
current_url = urlparse(browser.url)
url = "%s://%s%s" % (current_url.scheme, current_url.netloc, url)
cookies = browser.driver.get_cookies()
cookies = {cookie["name"]: cookie["value"] for cookie in cookies}
response = requests.get(url, verify=False, cookies=cookies)