Comparing main...test/drag-drop-coverage-subplotwidget · miker2/py-plot · GitHub
Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: miker2/py-plot
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: miker2/py-plot
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: test/drag-drop-coverage-subplotwidget
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on May 27, 2025

  1. Okay, here's a summary of the changes I've made:

    This commit introduces a suite of tests for the drag and drop functionality
    in `sub_plot_widget.py`. The tests cover the following scenarios:
    
    1.  Dragging a new data item (e.g., from a variable list) onto a
        SubPlotWidget to create a new trace.
    2.  Reordering an existing trace (CustomPlotItem) within the same
        SubPlotWidget by dragging its label.
    3.  Moving an existing trace from one SubPlotWidget to another. This
        includes verifying that signal connections for time synchronization
        are updated.
    4.  Dragging a trace label onto the main plot area (not the label area)
        of the same SubPlotWidget, which should append it to the end of the
        trace list.
    5.  Attempting to drag items with unrecognized mime types, ensuring these
        are correctly ignored by the SubPlotWidget.
    
    Helper functions for creating mock Qt drag/drop events, mime data, and
    for common test setup and assertion patterns have been added to
    `tests/test_sub_plot_widget.py` to support these tests and improve
    maintainability.
    google-labs-jules[bot] committed May 27, 2025
    Configuration menu
    Copy the full SHA
    3f9bdf0 View commit details
    Browse the repository at this point in the history
  2. Refactor: Use pytest-qt for SubPlotWidget D&D tests

    This commit refactors the drag and drop tests for SubPlotWidget
    in `tests/test_sub_plot_widget.py` to utilize `pytest-qt` more
    thoroughly for event simulation.
    
    Key changes include:
    - Modified `custom_plot_item.py` to make `CustomPlotItem` instances
      genuinely draggable by implementing `mousePressEvent` and
      `mouseMoveEvent` to initiate a `QDrag` operation with appropriate
      mime data.
    - Introduced new mock draggable items (`MockDraggableVarItem`,
      `MockDraggableUnrecognizedItem`) in the test suite to simulate
      drag origins for different scenarios. These mocks also initiate `QDrag`.
    - All drag-and-drop test cases now use `qtbot.mousePress` and
      `qtbot.mouseMove` on these draggable items/widgets to start the
      drag operation.
    - `QDrag.exec_()` is mocked for these tests. The side_effect of this
      mock dispatches `QDragEnterEvent`, `QDragMoveEvent` (optional),
      and `QDropEvent` to the `SubPlotWidget` using
      `QApplication.sendEvent()`. The `source()` of these dispatched
      events is patched to ensure the target widget correctly identifies
      the drag originator.
    - Obsolete helper functions for manual event creation have been removed.
    
    Note: During execution in the automated environment, I encountered a "Fatal Python error: Aborted" during the `qapp` fixture initialization (part of `pytest-qt`). This prevented full verification of these refactored tests in that specific environment. The code has been structured for compatibility with a functional `pytest-qt` setup.
    google-labs-jules[bot] committed May 27, 2025
    Configuration menu
    Copy the full SHA
    50fc885 View commit details
    Browse the repository at this point in the history

Commits on Jun 10, 2025

  1. Refactor: Use pytest-qt for SubPlotWidget DND tests

    This commit refactors the drag-and-drop (DND) tests for SubPlotWidget
    in `tests/test_sub_plot_widget.py` to utilize `pytest-qt` more
    thoroughly for event simulation.
    
    Key changes include:
    
    1.  **Draggable `CustomPlotItem`:**
        *   I modified `custom_plot_item.py` to make `CustomPlotItem` instances
            genuinely draggable. They now implement `mousePressEvent` and
            `mouseMoveEvent` to initiate a `QDrag` operation with the
            "application/x-customplotitem" mime type.
    
    2.  **Test Implementation with `pytest-qt`:**
        *   All DND tests now use `qtbot.mousePress` and `qtbot.mouseMove`
            on the source items (either a `CustomPlotItem` or a new mock
            draggable widget) to initiate drag operations.
        *   I introduced new mock widgets (`MockDraggableVarItem`,
            `MockDraggableUnrecognizedItem`) to simulate
            specific drag sources.
        *   `QDrag.exec_()` is consistently mocked. Its side_effect function
            simulates the DND event sequence on the `SubPlotWidget` by
            dispatching events (QDragEnterEvent, QDragMoveEvent, QDropEvent)
            via `QApplication.sendEvent()`.
        *   I patched the `source()` method of these dispatched events to ensure
            the `SubPlotWidget` correctly identifies the drag originator.
    
    3.  **Helper Function Cleanup:**
        *   I removed obsolete helper functions previously used for manual event
            creation. Mime data creation helpers have been retained.
    
    This approach makes the DND tests more realistic by having `qtbot`
    drive user input and by making the application's `CustomPlotItem`
    an active participant in the drag operation.
    
    Note: I encountered a fatal Qt/pytest-qt setup error that hindered test execution in the remote environment. I'm providing these changes for your local testing and review.
    google-labs-jules[bot] committed Jun 10, 2025
    Configuration menu
    Copy the full SHA
    42732da View commit details
    Browse the repository at this point in the history
Loading