Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
removed fixture, simplified test
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Kantor <benkantor@gmail.com>
  • Loading branch information
nickdelgrosso and bkntr committed May 10, 2021
1 parent 0d3720c commit 2265676
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions tests/unit_tests/gui/test_atlas_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,11 @@
from slicereg.gui.view_models.atlas_section import AtlasSectionViewModel


@pytest.fixture
def view_model() -> AtlasSectionViewModel:
MockCommandProvider = Mock(CommandProvider)
MockSignal = Mock(Signal)
model = AppModel(MockCommandProvider())
updated = MockSignal()
view_model = AtlasSectionViewModel(axis=0, _model=model, updated=updated)
return view_model


cases = [
(0, 'coronal_section_image'),
(1, 'axial_section_image'),
(2, 'sagittal_section_image'),
]


@pytest.mark.parametrize("axis, section_attr", cases)
def test_app_model_coronal_section_is_the_first_axis_of_the_atlas_volume_and_at_the_first_atlas_section_coordinate(axis, section_attr):
atlas_volume = np.random.randint(0, 100, (10, 10, 10), np.uint16)
Expand All @@ -44,13 +32,12 @@ def test_coronal_section_view_model_displays_the_coronal_section_image():
npt.assert_equal(app_model.coronal_section_image, view_model.section_image)



def test_update_coords(view_model: AtlasSectionViewModel):
app_model = view_model._model
app_model.atlas_volume = np.random.randint(0, 100, (10, 10, 10), np.uint16)
app_model.atlas_section_coords = (1, 2, 3)
expected = (2, 3)

args, kwargs = view_model.updated.emit.call_args
result = kwargs['dto'].coords
npt.assert_equal(result, expected)
def test_update_coords():
model = AppModel(
_commands=Mock(CommandProvider),
atlas_volume=np.random.randint(0, 100, (10, 10, 10), np.uint16),
)
view_model = AtlasSectionViewModel(axis=0, _model=model, updated=Mock(Signal))
model.atlas_section_coords = (1, 2, 3)
result = view_model.updated.emit.call_args[1]['dto']
npt.assert_equal(result.coords, (2, 3))

0 comments on commit 2265676

Please sign in to comment.