Skip to content

Commit

Permalink
changed how mock_event is created
Browse files Browse the repository at this point in the history
  • Loading branch information
YektaY committed Dec 11, 2023
1 parent ace4423 commit e1e35ac
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/badger/tests/test_run_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ def test_plotting(qtbot):
monitor.update_curves()


def test_click_graph(qtbot, mocker):
def test_click_graph(qtbot):
monitor = create_test_run_monitor()
sig_inspect_spy = QSignalSpy(monitor.sig_inspect)
monitor.plot_x_axis = True

mock_event = mocker.MagicMock(spec=QMouseEvent)
mock_event = QMouseEvent(QMouseEvent.MouseButtonPress, QPointF(350, 240), Qt.LeftButton, Qt.NoButton, Qt.NoModifier)
mock_event._scenePos = QPointF(350, 240)

orginal_value = monitor.inspector_variable.value()
Expand All @@ -121,7 +121,7 @@ def test_click_graph(qtbot, mocker):
# TODO: make asserts for other changes when the graph is clicked on by the user.


def test_x_axis_specification(qtbot, mocker):
def test_x_axis_specification(qtbot):
# check iteration/time drop down menu
monitor = create_test_run_monitor()

Expand Down Expand Up @@ -164,13 +164,12 @@ def test_x_axis_specification(qtbot, mocker):
plot_con_axis_time = monitor.plot_con.getAxis("bottom")
assert plot_con_axis_time.label.toPlainText().strip() == "time (s)"

mock_event = mocker.MagicMock(spec=QMouseEvent)
mock_event = QMouseEvent(QMouseEvent.MouseButtonPress, QPointF(550, 250), Qt.LeftButton, Qt.NoButton, Qt.NoModifier)
mock_event._scenePos = QPointF(550, 250)

monitor.on_mouse_click(mock_event)

# Check type of value
print(monitor.inspector_objective.value())
assert isinstance(monitor.inspector_objective.value(), float)
assert isinstance(monitor.inspector_variable.value(), float)
if monitor.vocs.constraint_names:
Expand Down

0 comments on commit e1e35ac

Please sign in to comment.