def test_invalid_expression(self): self.window._wait() with dialogs.assertError(2): self.layer.x = "vx*" self.layer.y = "vy&" with dialogs.assertError(3): self.layer.x = "hoeba(vx)" self.layer.x = "x(vx)" self.layer.y = "doesnotexist" with dialogs.assertError(2): self.layer.vx = "hoeba(vx)" self.layer.vy = "x(vx)" with dialogs.assertError(3): self.layer.weight = "hoeba(vx)" self.layer.statistic = "mean" # with dialogs.assertError(1): # self.layer.statistic = "blaat" self.layer.x = "x" self.layer.y = "y" self.layer.weight = "z" self.layer.statistic = "mean" #self.window._wait() # since this will be triggered, overrule it self.no_error_in_field = True
def test_invalid_expression(self): self.window._wait() with dialogs.assertError(2): self.layer.x = "vx*" self.layer.y = "vy&" with dialogs.assertError(3): self.layer.x = "hoeba(vx)" self.layer.x = "x(vx)" self.layer.y = "doesnotexist" with dialogs.assertError(2): self.layer.vx = "hoeba(vx)" self.layer.vy = "x(vx)" with dialogs.assertError(3): self.layer.weight = "hoeba(vx)" self.layer.statistic = "mean" # with dialogs.assertError(1): # self.layer.statistic = "blaat" self.layer.x = "x" self.layer.y = "y" self.layer.weight = "z" self.layer.statistic = "mean" #self.window._wait() # since this will be triggered, overrule it self.no_error_in_field = True
def test_favorite_selections(self): with dialogs.assertError(): self.window.action_selection_add_favorites.trigger() self.window.current_layer.dataset.select("x > 5") name = "test-selection-" + str(random.random()) with dialogs.settext(name): self.window.action_selection_add_favorites.trigger() self.assertIn(name, self.window.current_layer.dataset.favorite_selections) found = 0 found_index = 0 for i, action in enumerate(self.window._favorite_selections_actions): if action.text() == name: found += 1 index = i self.assertEqual(found, 1, "expect the entry to occur once, occurred %d" % found) with dialogs.setchoose(index): self.window.action_selection_remove_favorites.trigger() self.assertNotIn(name, self.window.current_layer.dataset.favorite_selections) found = 0 for action in self.window.menu_selection.actions(): if action.text() == name: found += 1 self.assertEqual(found, 0, "expect the entry to occur be removed, but it occurred %d" % found) self.window.dataset.favorite_selections.clear() with dialogs.assertError(): self.window.action_selection_remove_favorites.trigger() self.window.remove_layer() with dialogs.assertError(): self.window.action_selection_remove_favorites.trigger() with dialogs.assertError(): self.window.action_selection_add_favorites.trigger()
def test_favorite_selections(self): with dialogs.assertError(): self.window.action_selection_add_favorites.trigger() self.window.current_layer.dataset.select("x > 5") name = "test-selection-" + str(random.random()) with dialogs.settext(name): self.window.action_selection_add_favorites.trigger() self.assertIn( name, self.window.current_layer.dataset.favorite_selections) found = 0 found_index = 0 for i, action in enumerate( self.window._favorite_selections_actions): if action.text() == name: found += 1 index = i self.assertEqual( found, 1, "expect the entry to occur once, occurred %d" % found) with dialogs.setchoose(index): self.window.action_selection_remove_favorites.trigger() self.assertNotIn( name, self.window.current_layer.dataset.favorite_selections) found = 0 for action in self.window.menu_selection.actions(): if action.text() == name: found += 1 self.assertEqual( found, 0, "expect the entry to occur be removed, but it occurred %d" % found) self.window.dataset.favorite_selections.clear() with dialogs.assertError(): self.window.action_selection_remove_favorites.trigger() self.window.remove_layer() with dialogs.assertError(): self.window.action_selection_remove_favorites.trigger() with dialogs.assertError(): self.window.action_selection_add_favorites.trigger()
def test_selection_options(self): self.window.xlabel = "x" self.window.ylabel = "y" ##self.window._wait() # TODO: is this a bug? if we don't wait and directly do the selection, the ThreadPoolIndex ## is entered twice, not sure this can happen from the gui expression = "x < 0" vaex.ui.qt.set_choose(expression, True) QtTest.QTest.mouseClick(self.layer.button_selection_expression, QtCore.Qt.LeftButton) # test if the expressions ends up in the clipboard self.window.action_selection_copy.trigger() clipboard = QtGui.QApplication.clipboard() clipboard_text = clipboard.text() self.assertIn(expression, clipboard_text) self.window._wait() self.assertTrue(self.no_exceptions) filename = self.window.plot_to_png() self.compare(filename, get_comparison_image("example_xy_selection_on_x")) # select nothing self.window.action_select_none.trigger() self.window._wait() filename = self.window.plot_to_png() self.compare(filename, get_comparison_image("example_xy")) with dialogs.assertError(1): self.window.action_selection_copy.trigger() # paste the expression back print("paste back the expression") clipboard.setText(clipboard_text) self.window.action_selection_paste.trigger() print("waiting....") self.window._wait() filename = self.window.plot_to_png() self.compare(filename, get_comparison_image("example_xy_selection_on_x"))
def test_selection_options(self): self.window.xlabel = "x" self.window.ylabel = "y" ##self.window._wait() # TODO: is this a bug? if we don't wait and directly do the selection, the ThreadPoolIndex ## is entered twice, not sure this can happen from the gui expression = "x < 0" vaex.ui.qt.set_choose(expression, True) QtTest.QTest.mouseClick(self.layer.button_selection_expression, QtCore.Qt.LeftButton) # test if the expressions ends up in the clipboard self.window.action_selection_copy.trigger() clipboard = QtGui.QApplication.clipboard() clipboard_text = clipboard.text() self.assertIn(expression, clipboard_text) self.window._wait() self.assertTrue(self.no_exceptions) filename = self.window.plot_to_png() self.compare(filename, get_comparison_image("example_xy_selection_on_x")) # select nothing self.window.action_select_none.trigger() self.window._wait() filename = self.window.plot_to_png() self.compare(filename, get_comparison_image("example_xy")) with dialogs.assertError(1): self.window.action_selection_copy.trigger() # paste the expression back print("paste back the expression") clipboard.setText(clipboard_text) self.window.action_selection_paste.trigger() print("waiting....") self.window._wait() filename = self.window.plot_to_png() self.compare(filename, get_comparison_image("example_xy_selection_on_x"))