Merge "Add assertions to functional test test_download_package."

This commit is contained in:
Jenkins 2017-01-12 01:15:59 +00:00 committed by Gerrit Code Review
commit f04dd79b2d
2 changed files with 30 additions and 4 deletions

View File

@ -76,7 +76,16 @@ class UITestCase(testtools.TestCase):
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

@ -1728,11 +1728,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')
@ -1740,6 +1743,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