Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit test added for spectrum widget roi colour change #2233

Merged
merged 2 commits into from
Jun 24, 2024

Conversation

ashmeigh
Copy link
Collaborator

@ashmeigh ashmeigh commented Jun 20, 2024

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.

Co-authored-by: Mike Sullivan <[email protected]>
Co-authored-by: Ashley Meigh <[email protected]>
@ashmeigh ashmeigh requested review from samtygier-stfc and JackEAllen and removed request for samtygier-stfc June 20, 2024 16:05
@coveralls
Copy link

Coverage Status

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

Copy link
Collaborator

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tweaks to the tests

@coveralls
Copy link

Coverage Status

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

@samtygier-stfc samtygier-stfc added this pull request to the merge queue Jun 24, 2024
Merged via the queue into main with commit dd2a13f Jun 24, 2024
8 checks passed
@samtygier-stfc samtygier-stfc deleted the FLASH_spectrum_roi_color_test branch June 24, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants