mantidproject / mantidimaging

Graphical toolkit for neutron imaging.
https://mantidproject.github.io/mantidimaging
GNU General Public License v3.0
10 stars 6 forks source link

unit test added for spectrum widget roi colour change #2233

Closed ashmeigh closed 1 week ago

ashmeigh commented 2 weeks ago

Description

This pull request enhances the Spectrum Widget by adding unit tests to validate the ROI colour change functionality. Two main test scenarios have been implemented.

Test 1: Valid Color Change

Verifies that when a valid colour is selected and applied using onChangeColor(), the ROI colour (colour attribute) in the Spectrum Widget is correctly updated.

Test 2: Invalid Color Handling

Ensures that if an invalid colour is selected (detected by check_color_valid() returning False), the ROI colour remains unchanged from its initial state.

These tests utilize mock.Mock to simulate the behaviour of the colour selection dialog (openColorDialog) and the validation function (check_color_valid), providing controlled testing environments.

Testing

Added unit tests in spectrum_viewer/test/spectrum_test.py:

test_WHEN_colour_changed_THEN_roi_colour_is_set

test_WHEN_colour_is_not_valid_THEN_roi_colour_is_unchanged

Verified tests locally with Python unittest framework.

All tests passed successfully, confirming the accurate behaviour of ROI colour change handling.

Acceptance Criteria

To consider this pull request ready for acceptance and merge into the main branch, the following criteria should be met:

Unit Test Coverage:

Ensure that all newly added unit tests (test_WHEN_colour_changed_THEN_roi_colour_is_set and test_WHEN_colour_is_not_valid_THEN_roi_colour_is_unchanged) pass without errors or failures.

Manual Verification:

Manually verify in a development environment that the Spectrum Widget responds correctly to valid and invalid colour changes as defined in the tests.

coveralls commented 2 weeks ago

Coverage Status

coverage: 73.039% (+0.05%) from 72.992% when pulling d64ae01f31094e2be216ad0a730130ace1591026 on FLASH_spectrum_roi_color_test into f0433e57e2d08e1c771306299f1aa9b288a0caca on main.

coveralls commented 2 weeks ago

Coverage Status

coverage: 73.045% (+0.05%) from 72.992% when pulling a8abd7246c3ff1e9d4137b625ff3fc1d2a6d2fd7 on FLASH_spectrum_roi_color_test into f0433e57e2d08e1c771306299f1aa9b288a0caca on main.