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_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 test_import_dialog_file_without_selecting_file(appliance, dialog): """ Bugzilla: 1740796 Polarion: assignee: nansari initialEstimate: 1/8h caseposneg: positive casecomponent: Automate testSteps: 1. "Automation-->Automate--> Customization-->Import/Export--> Click export without a service dialog selected. 2. Exit this screen and edit a service dialog and save expectedResults: 1. Flash message: "At least 1 item must be selected for export" 2. Error flash message should not appear """ import_export = DialogImportExport(appliance) view = navigate_to(import_export, "DialogImportExport") view.export.click() view.flash.assert_message("At least 1 item must be selected for export") dialog.update({'label': fauxfactory.gen_alphanumeric()})