def import_datastore(appliance, import_data): """This fixture will help to import datastore file. To invoke this fixture, we need to pass parametrize import data with the help of `DatastoreImport`namedtuple. Usage: .. code-block:: python @pytest.mark.parametrize( "import_data", [DatastoreImport("datastore.zip", "from_domain_name", "to_domain_name")] ) def test_foo(import_datastore, import_data): pass """ # Download datastore file from FTP server fs = FTPClientWrapper(cfme_data.ftpserver.entities.datastores) file_path = fs.download(import_data.file_name) # Import datastore file to appliance datastore = appliance.collections.automate_import_exports.instantiate( import_type="file", file_path=file_path) domain = datastore.import_domain_from(import_data.from_domain, import_data.to_domain) assert domain.exists with update(domain): domain.enabled = True yield domain domain.delete_if_exists()
def test_upload_delete_custom_image_on_bundle(catalog_bundle): """ Bugzilla: 1487056 Polarion: assignee: nansari casecomponent: Services initialEstimate: 1/8h testSteps: 1. Create a catalog item 2. Create a catalog bundle 3. Upload a custom image to bundle 4. remove the image expectedResults: 1. 2. 3. 4. Upload and Remove image should work """ image = 'logo.png' fs = FTPClientWrapper(cfme_data.ftpserver.entities.others) file_path = fs.download(image) view = navigate_to(catalog_bundle, 'Details') view.entities.upload_image.fill(file_path) view.entities.upload_button.click() view.flash.assert_message( f'Custom Image file "{image}" successfully uploaded') view.entities.remove.click() view.flash.assert_message('Custom Image successfully removed')
def test_dialog_not_required_default_value( appliance, generic_catalog_item_with_imported_dialog, file_name): """ Bugzilla: 1783375 Polarion: assignee: nansari casecomponent: Services initialEstimate: 1/16h startsin: 5.10 """ catalog_item, _, ele_label = generic_catalog_item_with_imported_dialog service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog, catalog_item.name) # download yaml file fs = FTPClientWrapper(cfme_data.ftpserver.entities.dialogs) file_path = fs.download(file_name) with open(file_path) as stream: dialog_data = yaml.load(stream, Loader=yaml.BaseLoader) default_drop = dialog_data[0]["dialog_tabs"][0]["dialog_groups"][0][ "dialog_fields"][0]["default_value"] view = navigate_to(service_catalogs, "Order") assert view.fields("dropdown_list_1").read() == default_drop
def test_dialog_default_value_integer( appliance, generic_catalog_item_with_imported_dialog, file_name): """ Bugzilla: 1554780 Polarion: assignee: nansari casecomponent: Services initialEstimate: 1/4h testtype: functional startsin: 5.10 """ catalog_item, _, ele_label = generic_catalog_item_with_imported_dialog service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog, catalog_item.name) # download yaml file fs = FTPClientWrapper(cfme_data.ftpserver.entities.dialogs) file_path = fs.download(file_name) with open(file_path, "r") as stream: dialog_data = yaml.load(stream, Loader=yaml.BaseLoader) default_drop = dialog_data[0]["dialog_tabs"][0]["dialog_groups"][0][ "dialog_fields"][0]["default_value"] default_radio = dialog_data[0]["dialog_tabs"][0]["dialog_groups"][0][ "dialog_fields"][1]["default_value"] view = navigate_to(service_catalogs, "Order") assert (view.fields("dropdown").read() == default_drop and view.fields("radio").read() == default_radio)
def import_dialog(appliance, file_name): """This fixture will help to import dialog file.""" # Download dialog file from FTP server fs = FTPClientWrapper(cfme_data.ftpserver.entities.dialogs) file_path = fs.download(file_name) # Import dialog yml to appliance import_export = DialogImportExport(appliance) import_export.import_dialog(file_path) # Read yml to get the field name with open(file_path) as stream: dialog = yaml.load(stream, Loader=yaml.BaseLoader) # It returns list of dicts description = dialog[0].get("description") label = dialog[0].get("label") ele_label = dialog[0]['dialog_tabs'][0]['dialog_groups'][0][ 'dialog_fields'][0]['name'] # File name contains '.yml' or '.yaml', Hence replacing it. sd = appliance.collections.service_dialogs.instantiate( label=label, description=description) yield sd, ele_label sd.delete_if_exists()
def test_crud_imported_domains(import_data, temp_appliance_preconfig): """ Bugzilla: 1753586 Polarion: assignee: dgaikwad initialEstimate: 1/8h caseposneg: positive casecomponent: Automate """ # Download datastore file from FTP server fs = FTPClientWrapper(cfme_data.ftpserver.entities.datastores) file_path = fs.download(import_data.file_name) # Import datastore file to appliance datastore = temp_appliance_preconfig.collections.automate_import_exports.instantiate( import_type="file", file_path=file_path) domain = datastore.import_domain_from(import_data.from_domain, import_data.to_domain) assert domain.exists if import_data.file_name == "bz_1753586_system.zip": # Imported domains with source - "system" can not be deleted or updated as those are # defaults like ManageIQ and RedHat domains. view = navigate_to(domain, "Details") assert not view.configuration.is_displayed else: view = navigate_to(domain.parent, "All") with update(domain): domain.description = fauxfactory.gen_alpha() domain.delete() view.flash.assert_message( f'Automate Domain "{domain.description}": Delete successful')
def test_existing_domain_child_override(appliance, custom_domain, import_data): """ PR: https://github.com/ManageIQ/manageiq-ui-classic/pull/4912 Bugzilla: 1752875 Polarion: assignee: ghubale initialEstimate: 1/8h caseposneg: positive casecomponent: Automate setup: First three steps are performed manually to have datastore zip file 1. Create custom domain and copy class - "ManageIQ/System/Process" 2. Lock this domain 3. Navigate to Automation > automate > Import/export and click on "export all classes and instances to file" 4. Go to custom domain and unlock it. Remove instance - "ManageIQ/System/Process/" and copy - "ManageIQ/System/Process/Request" (you can copy more classes or methods or instances) to custom domain and again lock the domain. testSteps: 1. Navigate to Import/Export page and import the exported file 2. Select "Select domain you wish to import from:" - "custom_domain" and check Toggle All/None 3. Click on commit button. 4. Then navigate to custom domain and unlock it 5. Perform step 1, 2 and 3(In this case, domain will get imported) 6. Go to custom domain expectedResults: 1. 2. 3. You should see flash message: "Error: Selected domain is locked" 4. 5. Selected domain imported successfully 6. You should see existing as well as imported namespace, class, instance or method """ # Download datastore file from FTP server fs = FTPClientWrapper(cfme_data.ftpserver.entities.datastores) file_path = fs.download(import_data.file_name) # Import datastore file to appliance datastore = appliance.collections.automate_import_exports.instantiate( import_type="file", file_path=file_path) datastore.import_domain_from(import_data.from_domain, import_data.to_domain) view = appliance.browser.create_view(FileImportSelectorView) view.flash.assert_message("Error: Selected domain is locked") custom_domain.unlock() datastore.import_domain_from(import_data.from_domain, import_data.to_domain) view.flash.assert_no_error() view = navigate_to(custom_domain, 'Details') if not BZ(1752875).blocks: assert (view.datastore.tree.has_path('Datastore', f'{custom_domain.name}', 'System', 'Request')) assert view.datastore.tree.has_path('Datastore', f'{custom_domain.name}', 'System', 'Process')
def yaml_path(yaml_name): """ Returns yaml path of the file with yaml_name name""" yaml_name = "{}.yaml".format(yaml_name) try: fs = FTPClientWrapper(cfme_data.ftpserver.entities.reports) file_path = fs.download(yaml_name, os.path.join("/tmp", yaml_name)) except (FTPException, AttributeError): logger.exception("FTP download or YAML lookup of %s failed, defaulting to local", yaml_name) file_path = data_path.join("ui", "intelligence", yaml_name).realpath().strpath logger.info("Importing from data path: %s", file_path) return file_path
def test_import_domain_containing_playbook_method(request, appliance, setup_ansible_repository, import_data): """This test case tests support of Export/Import of Domain with Ansible Method Bugzilla: 1677575 Polarion: assignee: ghubale initialEstimate: 1/8h caseimportance: high caseposneg: positive testtype: functional startsin: 5.11 casecomponent: Automate tags: automate setup: 1. Add playbook repository 2. Create a new automate method with playbook type. 3. Fill the required fields, for instance repository and playbook. 4. Export this datastore. 5. Playbook method fields are stored as a names instead of IDs. (this is not possible via automate need to check manually in method yaml) testSteps: 1. Import the exported datastore and change name of playbook in method yaml to invalid playbook name(Note: These test steps needs to execute manually and then import datastore) expectedResults: 1. Proper error should be displayed while importing datastore with invalid playbook """ # Download datastore file from FTP server fs = FTPClientWrapper(cfme_data.ftpserver.entities.datastores) file_path = fs.download(import_data.file_name) # Import datastore file to appliance datastore = appliance.collections.automate_import_exports.instantiate( import_type="file", file_path=file_path) domain = datastore.import_domain_from(import_data.from_domain, import_data.to_domain) request.addfinalizer(domain.delete_if_exists) view = appliance.browser.create_view(FileImportSelectorView) # setup_ansible_repository.name is ansible repository name already there in datastore yml which # we are going to import. error_msg = ( f"Playbook 'invalid_1677575.yml' not found in repository '{setup_ansible_repository.name}'" ) view.flash.assert_message(text=error_msg, partial=True)
def _report(file_name, menu_name): collection = appliance.collections.reports # download the report from server fs = FTPClientWrapper(cfme_data.ftpserver.entities.reports) file_path = fs.download(file_name) # import the report collection.import_report(file_path) # instantiate report and return it report = collection.instantiate(type="My Company (All Groups)", subtype="Custom", menu_name=menu_name) request.addfinalizer(report.delete_if_exists) return report
def test_upload_blank_file(appliance, upload_file): """ Bugzilla: 1720611 Polarion: assignee: dgaikwad initialEstimate: 1/8h caseposneg: negative startsin: 5.10 casecomponent: Automate testSteps: 1. Create blank zip(test.zip) and yaml(test.yml) file 2. Navigate to Automation > Automate > Import/Export and upload test.zip file 3. Navigate to Automation > Automate > Customization > Import/Export and upload test.yml expectedResults: 1. 2. Error message should be displayed 3. Error message should be displayed """ # Download datastore file from FTP server fs = FTPClientWrapper(cfme_data.ftpserver.entities.datastores) file_path = fs.download(upload_file) if upload_file == "dialog_blank.yml": with LogValidator("/var/www/miq/vmdb/log/production.log", failure_patterns=[".*FATAL.*"]).waiting(timeout=120): # Import dialog yml to appliance import_export = DialogImportExport(appliance) view = navigate_to(import_export, "DialogImportExport") view.upload_file.fill(file_path) view.upload.click() view.flash.assert_message('Error: the uploaded file is blank') else: # Import datastore file to appliance datastore = appliance.collections.automate_import_exports.instantiate( import_type="file", file_path=file_path) view = navigate_to(appliance.collections.automate_import_exports, "All") with LogValidator("/var/www/miq/vmdb/log/production.log", failure_patterns=[".*FATAL.*"]).waiting(timeout=120): view.import_file.upload_file.fill(datastore.file_path) view.import_file.upload.click() view.flash.assert_message( "Error: import processing failed: domain: *")
def get_custom_report(appliance): collection = appliance.collections.reports # download the report from server fs = FTPClientWrapper(cfme_data.ftpserver.entities.reports) file_path = fs.download("testing_report.yaml") # import the report collection.import_report(file_path) # instantiate report and return it report = collection.instantiate( type="My Company (All Groups)", subtype="Custom", menu_name="testing report", title="testing report title", ) yield report report.delete_if_exists()
def test_dialog_default_value_selection( appliance, custom_categories, import_datastore, import_data, generic_catalog_item_with_imported_dialog, file_name): """ Bugzilla: 1579405 Polarion: assignee: nansari casecomponent: Services initialEstimate: 1/4h testtype: functional startsin: 5.10 """ catalog_item, _, ele_label = generic_catalog_item_with_imported_dialog service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog, catalog_item.name) # download yaml file fs = FTPClientWrapper(cfme_data.ftpserver.entities.dialogs) file_path = fs.download(file_name) with open(file_path) as stream: dialog_data = yaml.load(stream, Loader=yaml.BaseLoader) environment = dialog_data[0]["dialog_tabs"][0]["dialog_groups"][0][ "dialog_fields"][0]["default_value"] vm_size = dialog_data[0]["dialog_tabs"][0]["dialog_groups"][0][ "dialog_fields"][1]["default_value"] network = dialog_data[0]["dialog_tabs"][0]["dialog_groups"][0][ "dialog_fields"][2]["default_value"] additional_disks = dialog_data[0]["dialog_tabs"][0]["dialog_groups"][ 0]["dialog_fields"][3]["default_value"] view = navigate_to(service_catalogs, "Order") assert (view.fields("environment").read() == environment and view.fields("instance").read() == vm_size and view.fields("network").read() == network and view.fields("number_disk").read() == additional_disks)
def image_file_path(file_name): """ Returns file path of the file""" fs = FTPClientWrapper(cfme_data.ftpserver.entities.others) file_path = fs.download(file_name, os.path.join("/tmp", file_name)) return file_path