def test_delete_dialog_before_parent_item(catalog_item): service_dialog = ServiceDialog(label=catalog_item.dialog) service_dialog.delete() flash.assert_message_match( ("Dialog \"{}\": Error during 'destroy': Dialog cannot be deleted " + "because it is connected to other components.").format( catalog_item.dialog))
def dialog(): dialog_name = "dialog_" + fauxfactory.gen_alphanumeric() element_data = dict( ele_label="ele_" + fauxfactory.gen_alphanumeric(), ele_name=fauxfactory.gen_alphanumeric(), ele_desc="my ele desc", choose_type="Text Box", default_text_box="default value" ) service_dialog = ServiceDialog(label=dialog_name, description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") service_dialog.create(element_data) flash.assert_success_message('Dialog "{}" was added'.format(dialog_name)) yield service_dialog # fixture cleanup try: service_dialog.delete() except NoSuchElementException or TimeoutException: logger.warning('test_catalog_item: dialog yield fixture cleanup, dialog "{}" not ' 'found'.format(dialog_name))
def dialog(): dialog = "dialog_" + generate_random_string() service_dialog = ServiceDialog(label=dialog, description="my dialog", submit=True, cancel=True) service_dialog.create() flash.assert_success_message('Dialog "%s" was added' % dialog) yield dialog
def test_reorder_unsaved_elements(): # Automate BZ - https://bugzilla.redhat.com/show_bug.cgi?id=1238721 element_1_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Text Box", 'default_text_box': "Default text" } element_2_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Check Box", 'default_text_box': True, 'field_required': True } dialog = ServiceDialog(label=fauxfactory.gen_alphanumeric(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") dialog.create(element_1_data) dialog.update_element(element_2_data, element_1_data)
def dialog(): dialog = "dialog_" + generate_random_string() service_dialog = ServiceDialog(label=dialog, description="my dialog", submit=True, cancel=True) service_dialog.create() yield dialog
def test_update_service_dialog(): dialog = ServiceDialog(label=rand.generate_random_string(), description="my dialog", submit=True, cancel=True) dialog.create() with update(dialog): dialog.description = "my edited description"
def some_dialogs(request): to_delete = [] request.addfinalizer(lambda: map(lambda obj: obj.delete(), to_delete)) for i in range(15): desc = "test_paginator_{}".format(generate_random_string(16)) dialog = ServiceDialog(label=desc, description=desc) dialog.create() to_delete.append(dialog) return to_delete
def test_create_service_dialog(): dialog = ServiceDialog(label=rand.generate_random_string(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + rand.generate_random_string(), tab_desc="my tab desc", box_label="box_" + rand.generate_random_string(), box_desc="my box desc", ele_label="ele_" + rand.generate_random_string(), ele_name=rand.generate_random_string(), ele_desc="my ele desc", choose_type="Text Box", default_text_box="default value") dialog.create()
def test_service_dialog_duplicate_name(): dialog = ServiceDialog(label=rand.generate_random_string(), description="my dialog", submit=True, cancel=True) dialog.create() error_msg = version.pick({ version.LOWEST: "Dialog Label has already been taken", '5.3': "Label has already been taken" }) with error.expected(error_msg): dialog.create()
def test_delete_dialog_before_parent_item(catalog_item): service_dialog = ServiceDialog(label=catalog_item.dialog) service_dialog.delete() message = version.pick({'5.6': (("Dialog \"{}\": Error during delete: Dialog cannot be " + "deleted because it is connected to other components."). format(catalog_item.dialog)), '5.5': (("Dialog \"{}\": Error during 'destroy': Dialog cannot be " + "deleted because it is connected to other components."). format(catalog_item.dialog))}) flash.assert_message_match(message)
def dialog(): dialog = "dialog_" + generate_random_string() service_dialog = ServiceDialog(label=dialog, description="my dialog", submit=True, cancel=True, tab_label="tab_" + generate_random_string(), tab_desc="tab_desc", box_label="box_" + generate_random_string(), box_desc="box_desc", ele_label="ele_" + generate_random_string(), ele_name="service_name", ele_desc="ele_desc", choose_type="Text Box", default_text_box="default value") service_dialog.create() yield dialog
def dialog(): dialog = "dialog_" + generate_random_string() service_dialog = ServiceDialog(label=dialog, description="my dialog", submit=True, cancel=True, tab_label="tab_" + generate_random_string(), tab_desc="tab_desc", box_label="box_" + generate_random_string(), box_desc="box_desc", ele_label="ele_" + generate_random_string(), ele_name="service_name", ele_desc="ele_desc", choose_type="Text Box", default_text_box="default value") service_dialog.create() flash.assert_success_message('Dialog "%s" was added' % dialog) yield dialog
def test_radiobutton_dialog_element(): element_data = { 'ele_label': "ele_" + rand.generate_random_string(), 'ele_name': rand.generate_random_string(), 'ele_desc': rand.generate_random_string(), 'choose_type': "Radio Button" } dialog = ServiceDialog(label=rand.generate_random_string(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + rand.generate_random_string(), tab_desc="my tab desc", box_label="box_" + rand.generate_random_string(), box_desc="my box desc") dialog.create(element_data)
def some_dialogs(request): to_delete = [] request.addfinalizer(lambda: map(lambda obj: obj.delete(), to_delete)) for i in range(6): random_str = fauxfactory.gen_alphanumeric(16) element_data = dict(ele_label='ele_label_{}'.format(random_str), ele_name='ele_name_{}'.format(random_str), choose_type='Check Box') dialog = ServiceDialog(label='test_paginator_{}'.format(random_str), tab_label='tab_{}'.format(random_str), box_label='box_{}'.format(random_str)) dialog.create(element_data) to_delete.append(dialog) return to_delete
def dialog(): dialog = "dialog_" + fauxfactory.gen_alphanumeric() element_data = dict( ele_label="ele_" + fauxfactory.gen_alphanumeric(), ele_name=fauxfactory.gen_alphanumeric(), ele_desc="my ele desc", choose_type="Text Box", default_text_box="default value" ) service_dialog = ServiceDialog(label=dialog, description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") service_dialog.create(element_data) yield dialog
def test_radiobutton_dialog_element(): element_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Radio Button" } dialog = ServiceDialog(label=fauxfactory.gen_alphanumeric(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") dialog.create(element_data)
def test_delete_dialog_before_parent_item(catalog_item): service_dialog = ServiceDialog(label=catalog_item.dialog) service_dialog.delete() message = version.pick({ '5.6': (("Dialog \"{}\": Error during delete: Dialog cannot be " + "deleted because it is connected to other components.").format( catalog_item.dialog)), '5.5': (("Dialog \"{}\": Error during 'destroy': Dialog cannot be " + "deleted because it is connected to other components.").format( catalog_item.dialog)) }) flash.assert_message_match(message)
def test_textareabox_dialog_element(): element_data = { 'ele_label': "ele_" + rand.generate_random_string(), 'ele_name': rand.generate_random_string(), 'ele_desc': rand.generate_random_string(), 'choose_type': "Text Area Box", 'field_required': True } dialog = ServiceDialog(label=rand.generate_random_string(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + rand.generate_random_string(), tab_desc="my tab desc", box_label="box_" + rand.generate_random_string(), box_desc="my box desc") dialog.create(element_data)
def dialog(): dialog = "dialog_" + generate_random_string() element_data = dict( ele_label="ele_" + rand.generate_random_string(), ele_name=rand.generate_random_string(), ele_desc="my ele desc", choose_type="Text Box", default_text_box="default value" ) service_dialog = ServiceDialog(label=dialog, description="my dialog", submit=True, cancel=True, tab_label="tab_" + rand.generate_random_string(), tab_desc="my tab desc", box_label="box_" + rand.generate_random_string(), box_desc="my box desc") service_dialog.create(element_data) flash.assert_success_message('Dialog "%s" was added' % dialog) yield dialog
def test_create_service_dialog(): element_data = { 'ele_label': "ele_" + rand.generate_random_string(), 'ele_name': rand.generate_random_string(), 'ele_desc': rand.generate_random_string(), 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog(label=rand.generate_random_string(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + rand.generate_random_string(), tab_desc="my tab desc", box_label="box_" + rand.generate_random_string(), box_desc="my box desc") dialog.create(element_data)
def some_dialogs(request): to_delete = [] request.addfinalizer(lambda: map(lambda obj: obj.delete(), to_delete)) for i in range(6): random_str = fauxfactory.gen_alphanumeric(16) element_data = dict(ele_label='ele_label_{}'.format(random_str), ele_name='ele_name_{}'.format(random_str), choose_type='Check Box') dialog = ServiceDialog( label='test_paginator_{}'.format(random_str), tab_label='tab_{}'.format(random_str), box_label='box_{}'.format(random_str)) dialog.create(element_data) to_delete.append(dialog) return to_delete
def dialog(): dialog = "dialog_" + fauxfactory.gen_alphanumeric() element_data = dict( ele_label="ele_" + fauxfactory.gen_alphanumeric(), ele_name=fauxfactory.gen_alphanumeric(), ele_desc="my ele desc", choose_type="Text Box", default_text_box="default value" ) service_dialog = ServiceDialog(label=dialog, description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") service_dialog.create(element_data) return dialog
def test_create_service_dialog(): element_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog(label=fauxfactory.gen_alphanumeric(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") dialog.create(element_data)
def test_textareabox_dialog_element(): element_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Text Area Box", 'field_required': True } dialog = ServiceDialog(label=fauxfactory.gen_alphanumeric(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") dialog.create(element_data)
def dialog(): dialog = "dialog_" + fauxfactory.gen_alphanumeric() element_data = dict( ele_label="ele_" + fauxfactory.gen_alphanumeric(), ele_name=fauxfactory.gen_alphanumeric(), ele_desc="my ele desc", choose_type="Text Box", default_text_box="default value" ) service_dialog = ServiceDialog(label=dialog, description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") service_dialog.create(element_data) flash.assert_success_message('Dialog "{}" was added'.format(dialog)) yield dialog
def dialog(): dialog = "dialog_" + fauxfactory.gen_alphanumeric() element_data = dict( ele_label="ele_" + fauxfactory.gen_alphanumeric(), ele_name=fauxfactory.gen_alphanumeric(), ele_desc="my ele desc", choose_type="Text Box", default_text_box="default value" ) service_dialog = ServiceDialog(label=dialog, description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") service_dialog.create(element_data) flash.assert_success_message('Dialog "%s" was added' % dialog) return dialog
def test_service_dialog_duplicate_name(): element_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog(label=fauxfactory.gen_alphanumeric(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") dialog.create(element_data) with error.expected("Label has already been taken"): dialog.create(element_data)
def dialog(copy_instance, create_method): dialog = "dialog_" + fauxfactory.gen_alphanumeric() element_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Drop Down List", 'dynamic_chkbox': True } dialog = ServiceDialog(label="dialog_" + fauxfactory.gen_alphanumeric(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") dialog.create(element_data) yield dialog
def test_dropdownlist_dialog_element(): element_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Drop Down List" } dialog = ServiceDialog(label=fauxfactory.gen_alphanumeric(), element_data=element_data, description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") dialog.create()
def dialog(request): dialog_name = "dialog_" + fauxfactory.gen_alphanumeric() service_name = fauxfactory.gen_alphanumeric() element_data = dict( ele_label="ele_" + fauxfactory.gen_alphanumeric(), ele_name="service_name", ele_desc="my ele desc", choose_type="Text Box", default_text_box=service_name ) service_dialog = ServiceDialog(label=dialog_name, description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") service_dialog.create(element_data) request.addfinalizer(service_dialog.delete) yield dialog_name, service_name
def tagcontrol_dialog(): dialog = "dialog_" + fauxfactory.gen_alphanumeric() element_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Tag Control", 'field_category': "Service Level", 'field_required': True } servicedialog = ServiceDialog(label=dialog, description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") servicedialog.create(element_data) yield dialog
def test_datecontrol_dialog_element(): element_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Date Control", 'field_past_dates': True } dialog = ServiceDialog(label=fauxfactory.gen_alphanumeric(), element_data=element_data, description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") dialog.create()
def test_service_dialog_duplicate_name(): element_data = { 'ele_label': "ele_" + rand.generate_random_string(), 'ele_name': rand.generate_random_string(), 'ele_desc': rand.generate_random_string(), 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog(label=rand.generate_random_string(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + rand.generate_random_string(), tab_desc="my tab desc", box_label="box_" + rand.generate_random_string(), box_desc="my box desc") dialog.create(element_data) error_msg = version.pick({ version.LOWEST: "Dialog Label has already been taken", '5.3': "Label has already been taken" }) with error.expected(error_msg): dialog.create(element_data)
def test_delete_service_dialog(): dialog = ServiceDialog(label=rand.generate_random_string(), description="my dialog", submit=True, cancel=True) dialog.create() dialog.delete()
def test_reorder_elements(): element_1_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Text Box", 'default_text_box': "Default text" } element_2_data = { 'ele_label': "ele_" + fauxfactory.gen_alphanumeric(), 'ele_name': fauxfactory.gen_alphanumeric(), 'ele_desc': fauxfactory.gen_alphanumeric(), 'choose_type': "Check Box", 'default_text_box': True, 'field_required': True } dialog = ServiceDialog(label=fauxfactory.gen_alphanumeric(), description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc") dialog.create(element_1_data, element_2_data) dialog.reorder_elements(dialog.tab_label, dialog.box_label, element_1_data, element_2_data)
def dialog(): dialog_name = "dialog_" + fauxfactory.gen_alphanumeric() element_data = dict(ele_label="ele_" + fauxfactory.gen_alphanumeric(), ele_name=fauxfactory.gen_alphanumeric(), ele_desc="my ele desc", choose_type="Text Box", default_text_box="default value") service_dialog = ServiceDialog( label=dialog_name, description="my dialog", submit=True, cancel=True, tab_label="tab_" + fauxfactory.gen_alphanumeric(), tab_desc="my tab desc", box_label="box_" + fauxfactory.gen_alphanumeric(), box_desc="my box desc", element_data=element_data) service_dialog.create() flash.assert_success_message('Dialog "{}" was added'.format(dialog_name)) yield service_dialog # fixture cleanup try: service_dialog.delete() except NoSuchElementException or TimeoutException: logger.warning( 'test_catalog_item: dialog yield fixture cleanup, dialog "{}" not ' 'found'.format(dialog_name))
def test_service_dialog_duplicate_name(): dialog = ServiceDialog(label=rand.generate_random_string(), description="my dialog", submit=True, cancel=True) dialog.create() error_msg = version.pick({ 'default': "Dialog Label has already been taken", '5.3': "Label has already been taken" }) with error.expected(error_msg): dialog.create()
def test_delete_dialog_before_parent_item(catalog_item): service_dialog = ServiceDialog(label=catalog_item.dialog) service_dialog.delete() flash.assert_message_match(("Dialog \"{}\": Error during 'destroy': Dialog cannot be deleted " + "because it is connected to other components.").format(catalog_item.dialog))
def test_vmware_vimapi_hotadd_disk(request, testing_group, provider, testing_vm, domain, namespace, cls): """ Tests hot adding a disk to vmware vm. This test exercises the ``VMware_HotAdd_Disk`` method, located either in ``/Integration/VimApi/`` (<5.3) or ``/Integration/VMware/VimApi`` (5.3 and up). Steps: * It creates an instance in ``System/Request`` that can be accessible from eg. a button. * Then it creates a service dialog that contains a field with the desired disk size, the text field name should be ``size`` * Then it creates a button, that refers to the ``VMware_HotAdd_Disk`` in ``Request``. The button shall belong in the VM and instance button group. * After the button is created, it goes to a VM's summary page, clicks the button, enters the size of the disk and submits the dialog. * The test waits until the number of disks is raised. Metadata: test_flag: hotdisk, provision """ # Instance that calls the method and is accessible from the button if current_version() < "5.3": rel = "/Integration/VimApi/VMware_HotAdd_Disk" else: rel = "/Integration/VMware/VimApi/VMware_HotAdd_Disk" instance = Instance(name="VMware_HotAdd_Disk", values={ "rel5": rel, }, cls=cls) if not instance.exists(): request.addfinalizer(lambda: instance.delete() if instance.exists() else None) instance.create() # Dialog to put the disk capacity return element_data = { 'ele_label': "Disk size", 'ele_name': "size", 'ele_desc': "Disk size", 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog( label=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), submit=True, tab_label=fauxfactory.gen_alphanumeric(), tab_desc=fauxfactory.gen_alphanumeric(), box_label=fauxfactory.gen_alphanumeric(), box_desc=fauxfactory.gen_alphanumeric(), ) dialog.create(element_data) request.addfinalizer(lambda: dialog.delete()) # Button that will invoke the dialog and action button_name = fauxfactory.gen_alphanumeric() button = Button(group=testing_group, text=button_name, hover=button_name, dialog=dialog, system="Request", request="VMware_HotAdd_Disk") request.addfinalizer(button.delete_if_exists) button.create() # Now do the funny stuff def _get_disk_count(): return int( testing_vm.get_detail(properties=("Datastore Allocation Summary", "Number of Disks")).strip()) original_disk_count = _get_disk_count() toolbar.select(testing_group.text, button.text) fill(Input("size"), "1") pytest.sel.click(submit) flash.assert_no_errors() wait_for(lambda: original_disk_count + 1 == _get_disk_count(), num_sec=180, delay=5)
def test_vmware_vimapi_hotadd_disk( request, testing_group, provider_crud, provider_mgmt, testing_vm, domain, namespace, cls): """ Tests hot adding a disk to vmware vm Metadata: test_flag: hotdisk, provision """ # Instance that calls the method and is accessible from the button if current_version() < "5.3": rel = "/Integration/VimApi/VMware_HotAdd_Disk" else: rel = "/Integration/VMware/VimApi/VMware_HotAdd_Disk" instance = Instance( name="VMware_HotAdd_Disk", values={ "rel5": rel, }, cls=cls ) if not instance.exists(): request.addfinalizer(lambda: instance.delete() if instance.exists() else None) instance.create() # Dialog to put the disk capacity return element_data = { 'ele_label': "Disk size", 'ele_name': "size", 'ele_desc': "Disk size", 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog( label=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), submit=True, tab_label=fauxfactory.gen_alphanumeric(), tab_desc=fauxfactory.gen_alphanumeric(), box_label=fauxfactory.gen_alphanumeric(), box_desc=fauxfactory.gen_alphanumeric(), ) dialog.create(element_data) request.addfinalizer(lambda: dialog.delete()) # Button that will invoke the dialog and action button_name = fauxfactory.gen_alphanumeric() button = Button(group=testing_group, text=button_name, hover=button_name, dialog=dialog, system="Request", request="VMware_HotAdd_Disk") request.addfinalizer(button.delete_if_exists) button.create() # Now do the funny stuff def _get_disk_count(): return int(testing_vm.get_detail( properties=("Datastore Allocation Summary", "Number of Disks")).strip()) original_disk_count = _get_disk_count() toolbar.select(testing_group.text, button.text) fill(Input("size"), "1") pytest.sel.click(submit) flash.assert_no_errors() wait_for(lambda: original_disk_count + 1 == _get_disk_count(), num_sec=180, delay=5)
def test_vmware_vimapi_hotadd_disk(request, testing_group, provider, testing_vm, domain, cls): """ Tests hot adding a disk to vmware vm. This test exercises the ``VMware_HotAdd_Disk`` method, located in ``/Integration/VMware/VimApi`` Steps: * It creates an instance in ``System/Request`` that can be accessible from eg. a button. * Then it creates a service dialog that contains a field with the desired disk size, the text field name should be ``size`` * Then it creates a button, that refers to the ``VMware_HotAdd_Disk`` in ``Request``. The button shall belong in the VM and instance button group. * After the button is created, it goes to a VM's summary page, clicks the button, enters the size of the disk and submits the dialog. * The test waits until the number of disks is raised. Metadata: test_flag: hotdisk, provision """ meth = Method(name='parse_dialog_value_{}'.format(fauxfactory.gen_alpha()), data=dedent('''\ # Transfers the dialog value to the root so the VMware method can use it. $evm.root['size'] = $evm.object['dialog_size'] exit MIQ_OK '''), cls=cls) @request.addfinalizer def _remove_method(): if meth.exists(): meth.delete() meth.create() # Instance that calls the method and is accessible from the button instance = Instance( name="VMware_HotAdd_Disk_{}".format(fauxfactory.gen_alpha()), values={ "meth4": { 'on_entry': meth.name }, # To preparse the value "rel5": "/Integration/VMware/VimApi/VMware_HotAdd_Disk", }, cls=cls) @request.addfinalizer def _remove_instance(): if instance.exists(): instance.delete() instance.create() # Dialog to put the disk capacity element_data = { 'ele_label': "Disk size", 'ele_name': "size", 'ele_desc': "Disk size", 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog( label=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), submit=True, tab_label=fauxfactory.gen_alphanumeric(), tab_desc=fauxfactory.gen_alphanumeric(), box_label=fauxfactory.gen_alphanumeric(), box_desc=fauxfactory.gen_alphanumeric(), ) dialog.create(element_data) request.addfinalizer(dialog.delete) # Button that will invoke the dialog and action button_name = fauxfactory.gen_alphanumeric() button = Button(group=testing_group, text=button_name, hover=button_name, dialog=dialog, system="Request", request=instance.name) request.addfinalizer(button.delete_if_exists) button.create() def _get_disk_count(): return int( testing_vm.get_detail(properties=("Datastore Allocation Summary", "Number of Disks")).strip()) original_disk_count = _get_disk_count() logger.info('Initial disk count: {}'.format(original_disk_count)) toolbar.select(testing_group.text, button.text) fill(Input("size"), '1') pytest.sel.click(submit) flash.assert_no_errors() try: wait_for(lambda: original_disk_count + 1 == _get_disk_count(), num_sec=180, delay=5) finally: logger.info('End disk count: {}'.format(_get_disk_count()))
def test_delete_dialog_before_parent_item(catalog_item): service_dialog = ServiceDialog(label=catalog_item.dialog.label) service_dialog.delete() flash.assert_message_match(('Dialog \"{}\": Error during delete: Dialog cannot be' ' deleted because it is connected to other components.').format(catalog_item.dialog.label))
def test_vmware_vimapi_hotadd_disk( request, testing_group, provider, testing_vm, domain, cls): """ Tests hot adding a disk to vmware vm. This test exercises the ``VMware_HotAdd_Disk`` method, located in ``/Integration/VMware/VimApi`` Steps: * It creates an instance in ``System/Request`` that can be accessible from eg. a button. * Then it creates a service dialog that contains a field with the desired disk size, the text field name should be ``size`` * Then it creates a button, that refers to the ``VMware_HotAdd_Disk`` in ``Request``. The button shall belong in the VM and instance button group. * After the button is created, it goes to a VM's summary page, clicks the button, enters the size of the disk and submits the dialog. * The test waits until the number of disks is raised. Metadata: test_flag: hotdisk, provision """ meth = Method( name='parse_dialog_value_{}'.format(fauxfactory.gen_alpha()), data=dedent('''\ # Transfers the dialog value to the root so the VMware method can use it. $evm.root['size'] = $evm.object['dialog_size'] exit MIQ_OK '''), cls=cls) @request.addfinalizer def _remove_method(): if meth.exists(): meth.delete() meth.create() # Instance that calls the method and is accessible from the button instance = Instance( name="VMware_HotAdd_Disk_{}".format(fauxfactory.gen_alpha()), values={ "meth4": {'on_entry': meth.name}, # To preparse the value "rel5": "/Integration/VMware/VimApi/VMware_HotAdd_Disk", }, cls=cls ) @request.addfinalizer def _remove_instance(): if instance.exists(): instance.delete() instance.create() # Dialog to put the disk capacity element_data = { 'ele_label': "Disk size", 'ele_name': "size", 'ele_desc': "Disk size", 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog( label=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), submit=True, tab_label=fauxfactory.gen_alphanumeric(), tab_desc=fauxfactory.gen_alphanumeric(), box_label=fauxfactory.gen_alphanumeric(), box_desc=fauxfactory.gen_alphanumeric(), ) dialog.create(element_data) request.addfinalizer(dialog.delete) # Button that will invoke the dialog and action button_name = fauxfactory.gen_alphanumeric() button = Button(group=testing_group, text=button_name, hover=button_name, dialog=dialog, system="Request", request=instance.name) request.addfinalizer(button.delete_if_exists) button.create() def _get_disk_count(): return int(testing_vm.get_detail( properties=("Datastore Allocation Summary", "Number of Disks")).strip()) original_disk_count = _get_disk_count() logger.info('Initial disk count: %s', original_disk_count) toolbar.select(testing_group.text, button.text) fill(Input("size"), '1') pytest.sel.click(submit) flash.assert_no_errors() try: wait_for( lambda: original_disk_count + 1 == _get_disk_count(), num_sec=180, delay=5) finally: logger.info('End disk count: %s', _get_disk_count())