Skip to content

Commit

Permalink
Backport PR #1335
Browse files Browse the repository at this point in the history
  • Loading branch information
DolicaAkelloEgwel authored and samtygier-stfc committed Mar 25, 2022
1 parent 938e538 commit 405ee49
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/release_notes/2.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ Developer Changes
- #1259 : Update license year in code files and add pre-commit check
- #1243 #1276 : Stack selector based on datasets
- #1184 : Make more use of QTest in gui testing


2.3.1
-----

- #1332 : Load dataset dialog wont accept non standard names
6 changes: 5 additions & 1 deletion mantidimaging/gui/windows/load_dialog/presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ def do_update_flat_or_dark(self, field: Field, name: str, suffix: str):
if not selected_file:
return
selected_dir = Path(os.path.dirname(selected_file))
field.set_images(find_images(selected_dir, name, suffix, image_format=self.image_format, logger=logger))
images = find_images(selected_dir, name, suffix, image_format=self.image_format, logger=logger)
if not images:
base_name = os.path.basename(selected_file).rpartition("_")[0]
images = find_images(selected_dir, base_name, "", image_format=self.image_format, logger=logger)
field.set_images(images)

def get_parameters(self) -> LoadingParameters:
lp = LoadingParameters()
Expand Down
19 changes: 19 additions & 0 deletions mantidimaging/gui/windows/load_dialog/test/presenter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ def test_do_update_flat_or_dark(self, find_images):
find_images.assert_called_once_with(Path('/'), name, suffix, image_format='', logger=logger)
field.set_images.assert_called_once_with(find_images.return_value)

@mock.patch("mantidimaging.gui.windows.load_dialog.presenter.find_images")
def test_do_update_flat_or_dark_second_attempt(self, find_images):
file_name = "/aaa_0000.tiff"
name = "Name"
suffix = "Apples"
field = mock.MagicMock()
self.v.select_file.return_value = file_name
files_list = [file_name, "aaa_0001.tiff"]
find_images.side_effect = [[], files_list]

self.p.do_update_flat_or_dark(field, name, suffix)

calls = [
mock.call(Path('/'), name, suffix, image_format='', logger=logger),
mock.call(Path('/'), "aaa", "", image_format='', logger=logger)
]
find_images.assert_has_calls(calls)
field.set_images.assert_called_once_with(files_list)

def test_do_update_single_file(self):
file_name = "file_name"
name = "Name"
Expand Down

0 comments on commit 405ee49

Please sign in to comment.