def _test_drop_on_component_editor_grid(browser): project_dict, workspace_page = startup(browser) #find and get the 'assembly', and 'top' objects workspace_page.set_library_filter('Assembly') # put Assembly at top of lib assembly = workspace_page.find_library_button('Assembly') top = workspace_page.get_dataflow_figure('top', '') editor = top.editor_page(double_click=False, base_type='Assembly') editor.show_dataflow() editor_top = get_dataflow_fig_in_assembly_editor(workspace_page, 'top') # sort through these to find the correct 'top' chain = ActionChains(browser) chain.click_and_hold(assembly) chain.move_to_element( editor_top('header').find_element_by_xpath("..")).perform() chain.move_by_offset(200, 1).perform() release(chain) # don't bother checking to see if it appeared, # the UI box will appear and screw the test if it did closeout(project_dict, workspace_page)
def trap_callback(snmp_engine, state_reference, context_engine_id, context_name, var_binds, cb_ctx): if not len(var_binds) >= 1: return if not len(var_binds[0]) >= 2: return if var_binds[1][0].prettyPrint() != "1.3.6.1.6.3.1.1.4.1.0" or var_binds[ 1][1].prettyPrint() != "1.3.6.1.6.3.1.1.5.3": return if var_binds[2][0].prettyPrint() != "1.3.6.1.2.1.2.2.1.1.1.0": return if var_binds[4][1].prettyPrint() != "2": return switch_name = context_engine_id.asOctets().decode("latin1")[5:] interface_name = util.parse_interface_name(var_binds[2][1].prettyPrint()) search_text = "tag:" + switch_name + "_" + interface_name result_line = "" with open(traffy_config.ALLOCATION) as file: for line in file: line = line.rstrip() if search_text in line: result_line = line break if result_line != "": ip_address = result_line.split(",")[1] util.release(interface, ip_address) print("Released " + ip_address + " (" + switch_name + " / " + interface_name + ")")
def response_check(ip_address, mac_address): if config.ENABLE_SNMP: if interfaces_status_list.get(ip_address) != "2": return else: if util.arping(ip_address) is True: return util.release(interface, ip_address) print("Released " + ip_address + " / " + mac_address)
def _test_drop_on_component_editor(browser): project_dict, workspace_page = startup(browser) #find and get the 'assembly', and 'top' objects workspace_page.set_library_filter('Assembly') # put Assembly at top of lib assembly = workspace_page.find_library_button('Assembly') top = workspace_page.get_dataflow_figure('top', '') editor = top.editor_page(double_click=False, base_type='Assembly') editor.show_dataflow() #in order to get the elements in the editor workflow, we must #distinguish them from the elements in the main workflow editor_top = get_dataflow_fig_in_assembly_editor(workspace_page, 'top') # sort through these to find the correct 'top' names = [] for div in getDropableElements(editor_top)[:-1]: chain = drag_element_to(browser, assembly, div, False) check_highlighting( editor_top('content_area').element, True, "Top in component editor's content_area") release(chain) #deal with the modal dialog name = NameInstanceDialog(workspace_page).create_and_dismiss() names.append(name) ensure_names_in_workspace( workspace_page, names, "Dragging 'assembly' to 'top' (in component editor) in one of the " "drop areas did not produce a new element on page") #now test to see if all the new elements are children of 'top' #generate what the pathnames SHOULD be guess_pathnames = ["top." + name for name in names] #get the actual pathnames figs = workspace_page.get_dataflow_figures() pathnames = [get_pathname(browser, fig) for fig in figs] # see if they match up! (keeping in mind that there are more elements # we have pathnames for than we put there) for path in guess_pathnames: eq( path in pathnames, True, "An element did not drop into 'top' (in component editor) when " "dragged onto one of its drop areas.\nIt was created somewhere else" ) closeout(project_dict, workspace_page)
def _test_drop_on_existing_assembly(browser): project_dict, workspace_page = startup(browser) assembly = workspace_page.find_library_button('Assembly') outer_name = put_assembly_on_grid(workspace_page) outer_figure = workspace_page.get_dataflow_figure(outer_name) outer_path = outer_figure.pathname eq(outer_path, outer_name, "Assembly did not produce an instance on the grid") div = getDropableElements(outer_figure)[0] chain = drag_element_to(browser, assembly, div, False) check_highlighting( outer_figure('content_area').element, True, "Assembly's content_area") release(chain) middle_name = NameInstanceDialog(workspace_page).create_and_dismiss() middle_figure = workspace_page.get_dataflow_figure(middle_name) middle_path = middle_figure.pathname eq(middle_path, outer_path + '.' + middle_name, "Assembly did not produce an instance inside outer Assembly") div = getDropableElements(middle_figure)[0] chain = drag_element_to(browser, assembly, div, True) check_highlighting( middle_figure('content_area').element, True, "Assembly's content_area") release(chain) inner_name = NameInstanceDialog(workspace_page).create_and_dismiss() #expand the middle div so that the inner one shows up in the workspace. middle_figure('top_right').element.click() inner_figure = workspace_page.get_dataflow_figure(inner_name) inner_path = inner_figure.pathname eq(inner_path, middle_path + '.' + inner_name, "Assembly did not produce an instance inside of the middle Assembly") ensure_names_in_workspace( workspace_page, [outer_name, middle_name, inner_name], "Dragging Assembly onto Assembly did not create a new instance on page" ) closeout(project_dict, workspace_page)
def _test_drop_on_component_editor(browser): project_dict, workspace_page = startup(browser) #find and get the 'assembly', and 'top' objects workspace_page.set_library_filter('Assembly') # put Assembly at top of lib assembly = workspace_page.find_library_button('Assembly') top = workspace_page.get_dataflow_figure('top', '') editor = top.editor_page(double_click=False, base_type='Assembly') editor.show_dataflow() #in order to get the elements in the editor workflow, we must #distinguish them from the elements in the main workflow editor_top = get_dataflow_fig_in_assembly_editor(workspace_page, 'top') # sort through these to find the correct 'top' names = [] for div in getDropableElements(editor_top)[:-1]: chain = drag_element_to(browser, assembly, div, False) check_highlighting(editor_top('content_area').element, True, "Top in component editor's content_area") release(chain) #deal with the modal dialog name = NameInstanceDialog(workspace_page).create_and_dismiss() names.append(name) ensure_names_in_workspace(workspace_page, names, "Dragging 'assembly' to 'top' (in component editor) in one of the " "drop areas did not produce a new element on page") #now test to see if all the new elements are children of 'top' #generate what the pathnames SHOULD be guess_pathnames = ["top." + name for name in names] #get the actual pathnames figs = workspace_page.get_dataflow_figures() pathnames = [get_pathname(browser, fig) for fig in figs] # see if they match up! (keeping in mind that there are more elements # we have pathnames for than we put there) for path in guess_pathnames: eq(path in pathnames, True, "An element did not drop into 'top' (in component editor) when " "dragged onto one of its drop areas.\nIt was created somewhere else") closeout(project_dict, workspace_page)
def _test_drop_on_existing_assembly(browser): project_dict, workspace_page = startup(browser) assembly = workspace_page.find_library_button('Assembly') outer_name = put_assembly_on_grid(workspace_page) outer_figure = workspace_page.get_dataflow_figure(outer_name) outer_path = outer_figure.pathname eq(outer_path, outer_name, "Assembly did not produce an instance on the grid") div = getDropableElements(outer_figure)[0] chain = drag_element_to(browser, assembly, div, False) check_highlighting(outer_figure('content_area').element, True, "Assembly's content_area") release(chain) middle_name = NameInstanceDialog(workspace_page).create_and_dismiss() middle_figure = workspace_page.get_dataflow_figure(middle_name) middle_path = middle_figure.pathname eq(middle_path, outer_path + '.' + middle_name, "Assembly did not produce an instance inside outer Assembly") div = getDropableElements(middle_figure)[0] chain = drag_element_to(browser, assembly, div, True) check_highlighting(middle_figure('content_area').element, True, "Assembly's content_area") release(chain) inner_name = NameInstanceDialog(workspace_page).create_and_dismiss() #expand the middle div so that the inner one shows up in the workspace. middle_figure('top_right').element.click() inner_figure = workspace_page.get_dataflow_figure(inner_name) inner_path = inner_figure.pathname eq(inner_path, middle_path + '.' + inner_name, "Assembly did not produce an instance inside of the middle Assembly") ensure_names_in_workspace(workspace_page, [outer_name, middle_name, inner_name], "Dragging Assembly onto Assembly did not create a new instance on page") closeout(project_dict, workspace_page)
def _test_workspace_dragdrop(browser): project_dict, workspace_page = startup(browser) #find and get the 'assembly', and 'top' objects assembly = workspace_page.find_library_button('Assembly') top = workspace_page.get_dataflow_figure('top') names = [] for div in getDropableElements(top): chain = drag_element_to(browser, assembly, div, False) check_highlighting( top('content_area').element, True, "Top's content_area") release(chain) #deal with the modal dialog name = NameInstanceDialog(workspace_page).create_and_dismiss() names.append(name) ensure_names_in_workspace( workspace_page, names, "Dragging 'assembly' to 'top' in one of the drop areas did not " "produce a new element on page") # now test to see if all the new elements are children of 'top' # generate what the pathnames SHOULD be guess_pathnames = ["top." + name for name in names] # get the actual pathnames figs = workspace_page.get_dataflow_figures() pathnames = [get_pathname(browser, fig) for fig in figs] # see if they match up! (keeping in mind that there are more elements # we have pathnames for than we put there) for path in guess_pathnames: eq( path in pathnames, True, "An element did not drop into 'top' when " "dragged onto one of its drop areas.\nIt was created somewhere else" ) closeout(project_dict, workspace_page)
def _test_workspace_dragdrop(browser): project_dict, workspace_page = startup(browser) #find and get the 'assembly', and 'top' objects assembly = workspace_page.find_library_button('Assembly') top = workspace_page.get_dataflow_figure('top') names = [] for div in getDropableElements(top): chain = drag_element_to(browser, assembly, div, False) check_highlighting(top('content_area').element, True, "Top's content_area") release(chain) #deal with the modal dialog name = NameInstanceDialog(workspace_page).create_and_dismiss() names.append(name) ensure_names_in_workspace(workspace_page, names, "Dragging 'assembly' to 'top' in one of the drop areas did not " "produce a new element on page") # now test to see if all the new elements are children of 'top' # generate what the pathnames SHOULD be guess_pathnames = ["top." + name for name in names] # get the actual pathnames figs = workspace_page.get_dataflow_figures() pathnames = [get_pathname(browser, fig) for fig in figs] # see if they match up! (keeping in mind that there are more elements # we have pathnames for than we put there) for path in guess_pathnames: eq(path in pathnames, True, "An element did not drop into 'top' when " "dragged onto one of its drop areas.\nIt was created somewhere else") closeout(project_dict, workspace_page)
def _test_drop_on_component_editor_grid(browser): project_dict, workspace_page = startup(browser) #find and get the 'assembly', and 'top' objects workspace_page.set_library_filter('Assembly') # put Assembly at top of lib assembly = workspace_page.find_library_button('Assembly') top = workspace_page.get_dataflow_figure('top', '') editor = top.editor_page(double_click=False, base_type='Assembly') editor.show_dataflow() editor_top = get_dataflow_fig_in_assembly_editor(workspace_page, 'top') # sort through these to find the correct 'top' chain = ActionChains(browser) chain.click_and_hold(assembly) chain.move_to_element(editor_top('header').find_element_by_xpath("..")).perform() chain.move_by_offset(200, 1).perform() release(chain) # don't bother checking to see if it appeared, # the UI box will appear and screw the test if it did closeout(project_dict, workspace_page)
def _test_connections(browser): # Check connection frame functionality. project_dict, workspace_page = startup(browser) filename = pkg_resources.resource_filename('openmdao.examples.enginedesign', 'vehicle_singlesim.py') workspace_page.add_file(filename) # Replace 'top' with VehicleSim. top = workspace_page.get_dataflow_figure('top') top.remove() asm_name = 'sim' workspace_page.add_library_item_to_dataflow('vehicle_singlesim.VehicleSim', asm_name) # show dataflow for vehicle workspace_page.expand_object('sim') workspace_page.show_dataflow('sim.vehicle') workspace_page.hide_left() vehicle = workspace_page.get_dataflow_figure('vehicle', 'sim') # no connections between assembly vars conn_page = vehicle.connections_page() conn_page.move(-50, -100) eq(conn_page.dialog_title, 'Connections: vehicle') eq(conn_page.source_component, '-- Assembly --') eq(conn_page.target_component, '-- Assembly --') eq(conn_page.count_variable_connections(), 0) # two connections between engine and chassis conn_page.set_source_component('engine') conn_page.set_target_component('chassis') eq(conn_page.count_variable_figures(), 20) eq(conn_page.count_variable_connections(), 2) conn_page.show_connected_variables() time.sleep(0.5) eq(conn_page.count_variable_figures(), 4) eq(conn_page.count_variable_connections(), 2) eq(sorted(conn_page.get_variable_names()), ['engine_torque', 'engine_weight', 'mass_engine', 'torque']) # one connection between transmission and engine (RPM) conn_page.set_source_component('transmission') conn_page.set_target_component('engine') eq(conn_page.count_variable_figures(), 2) eq(conn_page.count_variable_connections(), 1) eq(sorted(conn_page.get_variable_names()), ['RPM', 'RPM']) # disconnect transmission conn_page.close() # Sometimes obscures dataflow. tranny = workspace_page.get_dataflow_figure('transmission', 'sim.vehicle') tranny.disconnect() vehicle = workspace_page.get_dataflow_figure('vehicle', 'sim') conn_page = vehicle.connections_page() conn_page.move(-50, -100) conn_page.show_connected_variables() # now there are no connections between transmission and engine conn_page.set_source_component('transmission') conn_page.set_target_component('engine') time.sleep(0.5) eq(conn_page.count_variable_figures(), 0) eq(conn_page.count_variable_connections(), 0) # reconnect transmission RPM to engine RPM conn_page.connect_vars('transmission.RPM', 'engine.RPM') time.sleep(1) eq(conn_page.count_variable_figures(), 2) eq(conn_page.count_variable_connections(), 1) eq(sorted(conn_page.get_variable_names()), ['RPM', 'RPM']) # no connections between transmission and chassis conn_page.set_target_component('chassis') time.sleep(0.5) eq(conn_page.count_variable_figures(), 0) eq(conn_page.count_variable_connections(), 0) # reconnect transmission torque to chassis torque by dragging # conn_page.connect_vars('transmission.torque_ratio', 'chassis.torque_ratio') conn_page.show_all_variables() torque_vars = conn_page.find_variable_name('torque_ratio') eq(len(torque_vars), 2) chain = ActionChains(browser) chain.click_and_hold(torque_vars[0]) chain.move_to_element(torque_vars[1]) release(chain) time.sleep(1.0) eq(conn_page.count_variable_connections(), 1) conn_page.show_connected_variables() time.sleep(0.5) eq(conn_page.count_variable_figures(), 2) eq(sorted(conn_page.get_variable_names()), ['torque_ratio', 'torque_ratio']) # no connections between vehicle assembly and transmission conn_page.set_source_component('') conn_page.set_target_component('transmission') time.sleep(0.5) eq(conn_page.count_variable_figures(), 0) eq(conn_page.count_variable_connections(), 0) # connect assembly variable to component variable conn_page.connect_vars('current_gear', 'transmission.current_gear') eq(conn_page.count_variable_figures(), 2) eq(conn_page.count_variable_connections(), 1) eq(sorted(conn_page.get_variable_names()), ['current_gear', 'current_gear']) # one connection from chassis component to vehicle assembly conn_page.set_source_component('chassis') conn_page.set_target_component('') eq(conn_page.count_variable_figures(), 2) eq(conn_page.count_variable_connections(), 1) eq(sorted(conn_page.get_variable_names()), ['acceleration', 'acceleration']) conn_page.close() # disconnect chassis chassis = workspace_page.get_dataflow_figure('chassis', 'sim.vehicle') chassis.disconnect() vehicle = workspace_page.get_dataflow_figure('vehicle', 'sim') conn_page = vehicle.connections_page() conn_page.move(-50, -100) eq(conn_page.count_variable_connections(), 0) # test invalid variable conn_page.connect_vars('chassis.acceleration', 'acceleration') message = NotifierPage.wait(workspace_page) eq(message, "Invalid source variable") # connect component variable to assembly variable conn_page.set_source_component('chassis') conn_page.connect_vars('chassis.acceleration', 'acceleration') eq(conn_page.count_variable_connections(), 1) conn_page.show_connected_variables() eq(sorted(conn_page.get_variable_names()), ['acceleration', 'acceleration']) conn_page.close() # Clean up. closeout(project_dict, workspace_page)
def _test_connections(browser): # Check connection frame functionality. project_dict, workspace_page = startup(browser) filename = pkg_resources.resource_filename( 'openmdao.examples.enginedesign', 'vehicle_singlesim.py') workspace_page.add_file(filename) # Replace 'top' with VehicleSim. top = workspace_page.get_dataflow_figure('top') top.remove() asm_name = 'sim' workspace_page.add_library_item_to_dataflow('vehicle_singlesim.VehicleSim', asm_name) # show dataflow for vehicle workspace_page.expand_object('sim') workspace_page.show_dataflow('sim.vehicle') workspace_page.hide_left() vehicle = workspace_page.get_dataflow_figure('vehicle', 'sim') # no connections between assembly vars conn_page = vehicle.connections_page() conn_page.move(-50, -100) eq(conn_page.dialog_title, 'Connections: vehicle') eq(conn_page.source_component, '-- Assembly --') eq(conn_page.target_component, '-- Assembly --') eq(conn_page.count_variable_connections(), 0) # two connections between engine and chassis conn_page.set_source_component('engine') conn_page.set_target_component('chassis') eq(conn_page.count_variable_figures(), 20) eq(conn_page.count_variable_connections(), 2) conn_page.show_connected_variables() time.sleep(0.5) eq(conn_page.count_variable_figures(), 4) eq(conn_page.count_variable_connections(), 2) eq(sorted(conn_page.get_variable_names()), ['engine_torque', 'engine_weight', 'mass_engine', 'torque']) # one connection between transmission and engine (RPM) conn_page.set_source_component('transmission') conn_page.set_target_component('engine') eq(conn_page.count_variable_figures(), 2) eq(conn_page.count_variable_connections(), 1) eq(sorted(conn_page.get_variable_names()), ['RPM', 'RPM']) # disconnect transmission conn_page.close() # Sometimes obscures dataflow. tranny = workspace_page.get_dataflow_figure('transmission', 'sim.vehicle') tranny.disconnect() vehicle = workspace_page.get_dataflow_figure('vehicle', 'sim') conn_page = vehicle.connections_page() conn_page.move(-50, -100) conn_page.show_connected_variables() # now there are no connections between transmission and engine conn_page.set_source_component('transmission') conn_page.set_target_component('engine') time.sleep(0.5) eq(conn_page.count_variable_figures(), 0) eq(conn_page.count_variable_connections(), 0) # reconnect transmission RPM to engine RPM conn_page.connect_vars('transmission.RPM', 'engine.RPM') time.sleep(1) eq(conn_page.count_variable_figures(), 2) eq(conn_page.count_variable_connections(), 1) eq(sorted(conn_page.get_variable_names()), ['RPM', 'RPM']) # no connections between transmission and chassis conn_page.set_target_component('chassis') time.sleep(0.5) eq(conn_page.count_variable_figures(), 0) eq(conn_page.count_variable_connections(), 0) # reconnect transmission torque to chassis torque by dragging # conn_page.connect_vars('transmission.torque_ratio', 'chassis.torque_ratio') conn_page.show_all_variables() torque_vars = conn_page.find_variable_name('torque_ratio') eq(len(torque_vars), 2) chain = ActionChains(browser) chain.click_and_hold(torque_vars[0]) chain.move_to_element(torque_vars[1]) release(chain) time.sleep(1.0) eq(conn_page.count_variable_connections(), 1) conn_page.show_connected_variables() time.sleep(0.5) eq(conn_page.count_variable_figures(), 2) eq(sorted(conn_page.get_variable_names()), ['torque_ratio', 'torque_ratio']) # no connections between vehicle assembly and transmission conn_page.set_source_component('') conn_page.set_target_component('transmission') time.sleep(0.5) eq(conn_page.count_variable_figures(), 0) eq(conn_page.count_variable_connections(), 0) # connect assembly variable to component variable conn_page.connect_vars('current_gear', 'transmission.current_gear') eq(conn_page.count_variable_figures(), 2) eq(conn_page.count_variable_connections(), 1) eq(sorted(conn_page.get_variable_names()), ['current_gear', 'current_gear']) # one connection from chassis component to vehicle assembly conn_page.set_source_component('chassis') conn_page.set_target_component('') eq(conn_page.count_variable_figures(), 2) eq(conn_page.count_variable_connections(), 1) eq(sorted(conn_page.get_variable_names()), ['acceleration', 'acceleration']) conn_page.close() # disconnect chassis chassis = workspace_page.get_dataflow_figure('chassis', 'sim.vehicle') chassis.disconnect() vehicle = workspace_page.get_dataflow_figure('vehicle', 'sim') conn_page = vehicle.connections_page() conn_page.move(-50, -100) eq(conn_page.count_variable_connections(), 0) # test invalid variable conn_page.connect_vars('chassis.acceleration', 'acceleration') message = NotifierPage.wait(workspace_page) eq(message, "Invalid source variable") # connect component variable to assembly variable conn_page.set_source_component('chassis') conn_page.connect_vars('chassis.acceleration', 'acceleration') eq(conn_page.count_variable_connections(), 1) conn_page.show_connected_variables() eq(sorted(conn_page.get_variable_names()), ['acceleration', 'acceleration']) conn_page.close() # Clean up. closeout(project_dict, workspace_page)
def _test_drop_onto_layered_div(browser): project_dict, workspace_page = startup(browser) # Add paraboloid and vehicle_threesim files file1_path = pkg_resources.resource_filename('openmdao.examples.simple', 'paraboloid.py') file2_path = pkg_resources.resource_filename( 'openmdao.examples.enginedesign', 'vehicle_threesim.py') workspace_page.add_file(file1_path) workspace_page.add_file(file2_path) # add VehicleSim2 to the globals sim_name = put_element_on_grid(workspace_page, 'VehicleSim2') # add Paraboloid to VehicleSim dataflow assembly sim = workspace_page.get_dataflow_figure(sim_name) paraboloid = workspace_page.find_library_button('Paraboloid') chain = drag_element_to(browser, paraboloid, sim('content_area').element, False) release(chain) paraboloid_name = NameInstanceDialog(workspace_page).create_and_dismiss() paraboloid_pathname = sim_name + "." + paraboloid_name # Open up the component editor for the sim_EPA_city inside the vehicle sim sim_EPA_city_driver = workspace_page.get_dataflow_figure( 'sim_EPA_city', sim_name) driver_editor = sim_EPA_city_driver.editor_page(base_type='Driver') driver_editor.move(-200, 0) driver_editor.show_workflow() # Confirm expected number of workflow component figures before adding one eq(len(driver_editor.get_workflow_component_figures()), 5) eq(len(workspace_page.get_workflow_component_figures()), 22) # Drop onto the object editor's workflow figure is no longer supported. # -- KTM # Drag paraboloid component into sim_EPA_city workflow #workspace_page('dataflow_tab').click() #workspace_page.expand_object(sim_name) #simsim_name = sim_name + '.' + 'sim_EPA_city' #workspace_page.add_object_to_workflow(paraboloid_pathname, simsim_name) ## Confirm there is one more workflow component figure in the editor #workspace_page('workflow_tab').click() #eq(len(driver_editor.get_workflow_component_figures()), 6) ## Confirm two more workflow component figures in the workspace as a whole #eq(len(workspace_page.get_workflow_component_figures()), 24) ## Confirm that the paraboloid has been added to the sim_EPA_city workflow ## by trying to access it. #obj = workspace_page.find_object_button(simsim_name + "." + paraboloid_name) # Don't see the reason to verfiy again that you can't add something to an # out-of-scope workflow. -- KTM ## Try dragging paraboloid component into vehicle workflow under sim_EPA_city ## should NOT add to the list of workflow component figures #workspace_page.expand_object(sim_name) #paraboloid_component = workspace_page.find_object_button(paraboloid_pathname) #vehicle_workflow_figure = workspace_page.get_workflow_figure("vehicle.driver") #chain = drag_element_to(browser, paraboloid_component, #vehicle_workflow_figure.components[0], True) #assert not vehicle_workflow_figure.highlighted #release(chain) ## Confirm that there is NOT a new workflow component figure in either place #eq(len(driver_editor.get_workflow_component_figures()), 6) #eq(len(workspace_page.get_workflow_component_figures()), 24) ## Confirm that the paraboloid has NOT been added to the vehicle workflow #assert paraboloid_name not in vehicle_workflow_figure.component_names # Clean up. closeout(project_dict, workspace_page)
def _test_component_to_complex_workflow(browser): project_dict, workspace_page = startup(browser) # Add paraboloid and vehicle_threesim files file1_path = pkg_resources.resource_filename('openmdao.examples.simple', 'paraboloid.py') file2_path = pkg_resources.resource_filename( 'openmdao.examples.enginedesign', 'vehicle_threesim.py') workspace_page.add_file(file1_path) workspace_page.add_file(file2_path) # create an instance of VehicleSim2 sim_name = put_element_on_grid(workspace_page, "VehicleSim2") # Drag paraboloid element into sim dataflow figure sim = workspace_page.get_dataflow_figure(sim_name) paraboloid = workspace_page.find_library_button('Paraboloid') chain = drag_element_to(browser, paraboloid, sim('content_area').element, False) release(chain) paraboloid_name = NameInstanceDialog(workspace_page).create_and_dismiss() paraboloid_pathname = sim_name + "." + paraboloid_name # Switch to Workflow pane and show the sim workflow workspace_page('workflow_tab').click() workspace_page.show_workflow(sim_name) # See how many workflow component figures there are before we add to it eq(len(workspace_page.get_workflow_component_figures()), 16) ############################################################################ # Drop paraboloid component onto the top level workflow for sim ############################################################################ workspace_page('dataflow_tab').click() workspace_page.expand_object(sim_name) workspace_page.add_object_to_workflow(paraboloid_pathname, sim_name) # Confirm that there is one more workflow component figure workspace_page('workflow_tab').click() eq(len(workspace_page.get_workflow_component_figures()), 17) # Confirm that the paraboloid has been added to the sim workflow by trying # to access it. obj = workspace_page.find_object_button(sim_name + "." + paraboloid_name) ############################################################################ # Drop paraboloid component onto the sim_acc workflow under sim ############################################################################ workspace_page('dataflow_tab').click() simsim_name = sim_name + '.sim_acc' workspace_page.add_object_to_workflow(paraboloid_pathname, simsim_name) # Confirm that there is one more workflow component figure workspace_page('workflow_tab').click() eq(len(workspace_page.get_workflow_component_figures()), 18) # Confirm that the paraboloid has been added to the sim workflow by trying # to access it. obj = workspace_page.find_object_button(sim_name + "." + paraboloid_name) ############################################################################ # Drop paraboloid component onto the vehicle workflow under sim_acc # This should NOT work since the paraboloid is not in the vehicle assembly ############################################################################ # These error messages are tested in SequentialFlow, though we may want # to have one test that makes sure that the error dialog makes it through. #workspace_page('dataflow_tab').click() #workspace_page.expand_object(simsim_name) #simsimsim_name = simsim_name + '.vehicle' #workspace_page.add_object_to_workflow(paraboloid_pathname, simsimsim_name) #message = NotifierPage.wait(workspace_page) #eq(message, "x") # Confirm that there is NOT a new workflow component figure #workspace_page('workflow_tab').click() #eq(len(workspace_page.get_workflow_component_figures()), 18) # Clean up. closeout(project_dict, workspace_page)
def _test_drop_onto_layered_div(browser): project_dict, workspace_page = startup(browser) # Add paraboloid and vehicle_threesim files file1_path = pkg_resources.resource_filename('openmdao.examples.simple', 'paraboloid.py') file2_path = pkg_resources.resource_filename('openmdao.examples.enginedesign', 'vehicle_threesim.py') workspace_page.add_file(file1_path) workspace_page.add_file(file2_path) # add VehicleSim2 to the globals sim_name = put_element_on_grid(workspace_page, 'VehicleSim2') # add Paraboloid to VehicleSim dataflow assembly sim = workspace_page.get_dataflow_figure(sim_name) paraboloid = workspace_page.find_library_button('Paraboloid') chain = drag_element_to(browser, paraboloid, sim('content_area').element, False) release(chain) paraboloid_name = NameInstanceDialog(workspace_page).create_and_dismiss() paraboloid_pathname = sim_name + "." + paraboloid_name # Open up the component editor for the sim_EPA_city inside the vehicle sim sim_EPA_city_driver = workspace_page.get_dataflow_figure('sim_EPA_city', sim_name) driver_editor = sim_EPA_city_driver.editor_page(base_type='Driver') driver_editor.move(-200, 0) driver_editor.show_workflow() # Confirm expected number of workflow component figures before adding one eq(len(driver_editor.get_workflow_component_figures()), 5) eq(len(workspace_page.get_workflow_component_figures()), 22) # Drop onto the object editor's workflow figure is no longer supported. # -- KTM # Drag paraboloid component into sim_EPA_city workflow #workspace_page('dataflow_tab').click() #workspace_page.expand_object(sim_name) #simsim_name = sim_name + '.' + 'sim_EPA_city' #workspace_page.add_object_to_workflow(paraboloid_pathname, simsim_name) ## Confirm there is one more workflow component figure in the editor #workspace_page('workflow_tab').click() #eq(len(driver_editor.get_workflow_component_figures()), 6) ## Confirm two more workflow component figures in the workspace as a whole #eq(len(workspace_page.get_workflow_component_figures()), 24) ## Confirm that the paraboloid has been added to the sim_EPA_city workflow ## by trying to access it. #obj = workspace_page.find_object_button(simsim_name + "." + paraboloid_name) # Don't see the reason to verfiy again that you can't add something to an # out-of-scope workflow. -- KTM ## Try dragging paraboloid component into vehicle workflow under sim_EPA_city ## should NOT add to the list of workflow component figures #workspace_page.expand_object(sim_name) #paraboloid_component = workspace_page.find_object_button(paraboloid_pathname) #vehicle_workflow_figure = workspace_page.get_workflow_figure("vehicle.driver") #chain = drag_element_to(browser, paraboloid_component, #vehicle_workflow_figure.components[0], True) #assert not vehicle_workflow_figure.highlighted #release(chain) ## Confirm that there is NOT a new workflow component figure in either place #eq(len(driver_editor.get_workflow_component_figures()), 6) #eq(len(workspace_page.get_workflow_component_figures()), 24) ## Confirm that the paraboloid has NOT been added to the vehicle workflow #assert paraboloid_name not in vehicle_workflow_figure.component_names # Clean up. closeout(project_dict, workspace_page)
def _test_component_to_complex_workflow(browser): project_dict, workspace_page = startup(browser) # Add paraboloid and vehicle_threesim files file1_path = pkg_resources.resource_filename('openmdao.examples.simple', 'paraboloid.py') file2_path = pkg_resources.resource_filename('openmdao.examples.enginedesign', 'vehicle_threesim.py') workspace_page.add_file(file1_path) workspace_page.add_file(file2_path) # create an instance of VehicleSim2 sim_name = put_element_on_grid(workspace_page, "VehicleSim2") # Drag paraboloid element into sim dataflow figure sim = workspace_page.get_dataflow_figure(sim_name) paraboloid = workspace_page.find_library_button('Paraboloid') chain = drag_element_to(browser, paraboloid, sim('content_area').element, False) release(chain) paraboloid_name = NameInstanceDialog(workspace_page).create_and_dismiss() paraboloid_pathname = sim_name + "." + paraboloid_name # Switch to Workflow pane and show the sim workflow workspace_page('workflow_tab').click() workspace_page.show_workflow(sim_name) # See how many workflow component figures there are before we add to it eq(len(workspace_page.get_workflow_component_figures()), 16) ############################################################################ # Drop paraboloid component onto the top level workflow for sim ############################################################################ workspace_page('dataflow_tab').click() workspace_page.expand_object(sim_name) workspace_page.add_object_to_workflow(paraboloid_pathname, sim_name) # Confirm that there is one more workflow component figure workspace_page('workflow_tab').click() eq(len(workspace_page.get_workflow_component_figures()), 17) # Confirm that the paraboloid has been added to the sim workflow by trying # to access it. obj = workspace_page.find_object_button(sim_name + "." + paraboloid_name) ############################################################################ # Drop paraboloid component onto the sim_acc workflow under sim ############################################################################ workspace_page('dataflow_tab').click() simsim_name = sim_name + '.sim_acc' workspace_page.add_object_to_workflow(paraboloid_pathname, simsim_name) # Confirm that there is one more workflow component figure workspace_page('workflow_tab').click() eq(len(workspace_page.get_workflow_component_figures()), 18) # Confirm that the paraboloid has been added to the sim workflow by trying # to access it. obj = workspace_page.find_object_button(sim_name + "." + paraboloid_name) ############################################################################ # Drop paraboloid component onto the vehicle workflow under sim_acc # This should NOT work since the paraboloid is not in the vehicle assembly ############################################################################ # These error messages are tested in SequentialFlow, though we may want # to have one test that makes sure that the error dialog makes it through. #workspace_page('dataflow_tab').click() #workspace_page.expand_object(simsim_name) #simsimsim_name = simsim_name + '.vehicle' #workspace_page.add_object_to_workflow(paraboloid_pathname, simsimsim_name) #message = NotifierPage.wait(workspace_page) #eq(message, "x") # Confirm that there is NOT a new workflow component figure #workspace_page('workflow_tab').click() #eq(len(workspace_page.get_workflow_component_figures()), 18) # Clean up. closeout(project_dict, workspace_page)