Add assertions to functional test test_download_package.

Currently, sanity_check.TestSuitePackages.test_download_package
lacks any assertions, which means the test isn't really a test.

This change modifies base.py to add automatic downloading of
application/octet-stream MIME type files (i.e. zip files)
to FireFox, such that now test_download_package can assert
that the file was successfully downloaded and that the right
file was downloaded.

Change-Id: I72917daae9e072bec380aac56b5d255c41794988
This commit is contained in:
Felipe Monteiro 2017-01-05 02:15:38 +00:00
parent 5d189b92e5
commit 5a76697f04
2 changed files with 30 additions and 4 deletions

View File

@ -88,7 +88,16 @@ class UITestCase(BaseDeps):
def setUp(self):
super(UITestCase, self).setUp()
self.driver = webdriver.Firefox()
# Enables zip files to be automatically saved to disk, without opening
# a browser dialog.
fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.folderList", 2)
fp.set_preference("browser.download.manager.showWhenStarting", False)
fp.set_preference("browser.download.dir", os.getcwd())
fp.set_preference("browser.helperApps.neverAsk.saveToDisk",
"application/octet-stream")
self.driver = webdriver.Firefox(firefox_profile=fp)
self.addCleanup(self.driver.quit)
self.driver.maximize_window()
self.driver.get(cfg.common.horizon_url + '/app-catalog/environments')

View File

@ -1488,11 +1488,14 @@ class TestSuitePackages(base.PackageTestCase):
c.TagInDetails).text)
def test_download_package(self):
"""Test check ability to download package from repository
"""Test check ability to download package from repository.
Scenario:
1. Navigate to 'Packages' page
2. Select PostgreSQL package and click on "More>Download Package"
1. Navigate to 'Packages' page.
2. Select PostgreSQL package and click on "More>Download Package".
3. Wait for the package to download.
4. Open the archive and check that the files match the expected
list of files.
"""
self.navigate_to('Manage')
self.go_to_submenu('Packages')
@ -1500,6 +1503,20 @@ class TestSuitePackages(base.PackageTestCase):
self.select_action_for_package(self.postgre_id, 'more')
self.select_action_for_package(self.postgre_id, 'download_package')
time.sleep(3) # Wait for file to download.
downloaded_archive_file = 'postgresql.zip'
expected_file_list = ['Classes/mock_muranopl.yaml', 'manifest.yaml',
'UI/mock_ui.yaml']
if os.path.isfile(downloaded_archive_file):
zf = zipfile.ZipFile(downloaded_archive_file, 'r')
self.assertEqual(sorted(expected_file_list), sorted(zf.namelist()))
os.remove(downloaded_archive_file) # Clean up.
else:
self.fail('Failed to download {0}.'.format(
downloaded_archive_file))
def test_check_toggle_enabled_package(self):
"""Test check ability to make package active or inactive