How to use toggle_viewer method in dbt-osmosis

Best Python code snippet using dbt-osmosis_python

test_ui.py

Source:test_ui.py Github

copy

Full Screen

...25 assert cubeviz_layout._active_cube is cubeviz_layout.right_view26 select_viewer(qtbot, cubeviz_layout.left_view)27 assert_active_view_and_cube(cubeviz_layout, cubeviz_layout.left_view)28def test_toggle_viewer_mode(qtbot, cubeviz_layout):29 toggle_viewer(qtbot, cubeviz_layout)30 assert cubeviz_layout._single_viewer_mode == True31 assert_active_view_and_cube(cubeviz_layout, cubeviz_layout.single_view)32 toggle_viewer(qtbot, cubeviz_layout)33 assert cubeviz_layout._single_viewer_mode == False34 assert_active_view_and_cube(cubeviz_layout, cubeviz_layout.left_view)35def test_remember_active_viewer(qtbot, cubeviz_layout):36 """Make sure that the active viewer in the current layout is remembered"""37 # Change active viewer in the split mode viewer38 select_viewer(qtbot, cubeviz_layout.right_view)39 assert_active_view_and_cube(cubeviz_layout, cubeviz_layout.right_view)40 # Change to the single mode viewer41 toggle_viewer(qtbot, cubeviz_layout)42 assert_active_view_and_cube(cubeviz_layout, cubeviz_layout.single_view)43 # Change active viewer in the single mode viewer44 select_viewer(qtbot, cubeviz_layout.specviz)45 assert cubeviz_layout._active_view == cubeviz_layout.specviz46 assert cubeviz_layout._active_cube == cubeviz_layout.single_view47 # Change back to the split mode viewer48 toggle_viewer(qtbot, cubeviz_layout)49 assert_active_view_and_cube(cubeviz_layout, cubeviz_layout.right_view)50 # Change back to the single mode viewer51 toggle_viewer(qtbot, cubeviz_layout)52 assert cubeviz_layout._active_view == cubeviz_layout.specviz53 assert cubeviz_layout._active_cube == cubeviz_layout.single_view54@pytest.mark.parametrize('viewer_index', [0, 1, 2, 3])55def test_sync_checkboxes(qtbot, cubeviz_layout, viewer_index):56 """This test simply makes sure that the checkbox changes the synced state57 of the corresponding viewer. It does not test the effects of syncing on the58 viewer indices.59 """60 # When testing the single viewer checkbox, first toggle to single viewer mode61 if viewer_index == 0:62 toggle_viewer(qtbot, cubeviz_layout)63 checkbox = cubeviz_layout._synced_checkboxes[viewer_index]64 viewer = cubeviz_layout.all_views[viewer_index]65 left_click(qtbot, checkbox)66 assert viewer._widget.synced == False67 left_click(qtbot, checkbox)68 assert viewer._widget.synced == True69def check_data_component(layout, combo, index, widget):70 combo.setCurrentIndex(index)71 current_label = DEFAULT_DATA_LABELS[index]72 assert combo.currentText() == current_label73 np.testing.assert_allclose(74 widget.layers[0].state.get_sliced_data(),75 layout._data[current_label][layout.synced_index])76def setup_combo_and_index(qtbot, layout, index):77 if index == 0:78 toggle_viewer(qtbot, layout)79 combo = getattr(layout.ui, 'single_viewer_combo')80 current_index = 081 else:82 combo = getattr(layout.ui, 'viewer{0}_combo'.format(index))83 current_index = index - 184 return combo, current_index85@pytest.mark.parametrize('viewer_index', [0, 1, 2, 3])86def test_viewer_dropdowns(qtbot, cubeviz_layout, viewer_index):87 combo, current_index = setup_combo_and_index(88 qtbot, cubeviz_layout, viewer_index)89 if viewer_index == 0:90 toggle_viewer(qtbot, cubeviz_layout)91 combo = getattr(cubeviz_layout.ui, 'single_viewer_combo')92 current_index = 093 else:94 combo = getattr(cubeviz_layout.ui, 'viewer{0}_combo'.format(viewer_index))95 current_index = viewer_index - 196 widget = cubeviz_layout.all_views[viewer_index]._widget97 # Make sure there are only three data components currently98 assert combo.count() == 399 # Make sure starting index is set appropriately100 assert combo.currentIndex() == current_index101 for i in range(3):102 current_index = (current_index + 1) % 3103 check_data_component(cubeviz_layout, combo, current_index, widget)104def test_add_data_component(qtbot, cubeviz_layout):105 new_label = 'QuirkyLabel'106 new_data = np.random.random(cubeviz_layout._data.shape)107 cubeviz_layout._data.add_component(new_data, new_label)108 for viewer_index in range(4):109 combo, current_index = setup_combo_and_index(110 qtbot, cubeviz_layout, viewer_index)111 widget = cubeviz_layout.all_views[viewer_index]._widget112 # Make sure the new index is there113 assert combo.count() == 4114 # Make sure the index hasn't changed (this might behave differently in the future)115 assert combo.currentIndex() == current_index116 # Make sure none of the original components have changed117 for i in range(3):118 check_data_component(cubeviz_layout, combo, i, widget)119 # Make sure the new data is displayed when selected120 combo.setCurrentIndex(3)121 assert combo.currentText() == new_label122 np.testing.assert_allclose(123 widget.layers[0].state.get_sliced_data(),124 cubeviz_layout._data[new_label][cubeviz_layout.synced_index])125 # Toggle back to split viewer mode if necessary126 if viewer_index == 0:...

Full Screen

Full Screen

viewer.py

Source:viewer.py Github

copy

Full Screen

...39 self.widget = View()40 self.widget.show()41 self.show_viewer_button = QtWidgets.QPushButton('Toggle Viewer')42 self.controls.append((self.show_viewer_button, self.toggle_viewer, self.show_viewer_button.clicked))43 def toggle_viewer(self):44 self.widget.setVisible(not self.widget.isVisible())45 @ComputeNode.Decorators.show_ui_computation46 def compute(self):47 self.start_spinner_signal.emit()48 image = self.get_first_param('image')49 if image.value:50 qim = ImageQt.ImageQt(image.value)51 self.widget.setPixmap(qim)52 self.stop_spinner_signal.emit()53 super().compute()54 def terminate(self):55 if self.widget:56 self.widget.setParent(None)57 del self.widget...

Full Screen

Full Screen

helpers.py

Source:helpers.py Github

copy

Full Screen

...6 'reset_app_state']7TEST_DATA_PATH = os.path.join(os.path.dirname(__file__), 'data')8def left_click(qtbot, widget):9 qtbot.mouseClick(widget, QtCore.Qt.LeftButton)10def toggle_viewer(qtbot, layout):11 left_click(qtbot, layout.button_toggle_image_mode)12def select_viewer(qtbot, viewer):13 left_click(qtbot, viewer._widget)14def enter_slice_text(qtbot, layout, text):15 widget = layout._slice_controller._slice_textbox16 widget.setText(str(text))17 qtbot.keyClick(widget, QtCore.Qt.Key_Enter)18def enter_wavelength_text(qtbot, layout, text):19 widget = layout._slice_controller._wavelength_textbox20 widget.setText(str(text))21 qtbot.keyClick(widget, QtCore.Qt.Key_Enter)22def sync_all_viewers(qtbot, layout):23 left_click(qtbot, layout.ui.sync_button)24def create_glue_app():25 filename = os.path.join(TEST_DATA_PATH, 'data_cube.fits.gz')26 # We need to make sure that the data factories have been instantiated27 # before creating the glue application below. Otherwise the test data file28 # will not be recognized and the application will hang waiting for user input.29 from ..data_factories import DataFactoryConfiguration30 dfc = DataFactoryConfiguration()31 app = GlueApplication()32 app.run_startup_action('cubeviz')33 app.load_data(filename)34 app.setVisible(True)35 return app36def reset_app_state(qtbot, layout):37 sync_all_viewers(qtbot, layout)38 # Restore the text and index to a known state39 enter_slice_text(qtbot, layout, '1024')40 if layout._single_viewer_mode:41 toggle_viewer(qtbot, layout)42 if layout._active_view is not layout.left_view:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run dbt-osmosis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful