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

Commit

Permalink
moving tested user commands to viewmodels
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdelgrosso committed May 10, 2021
1 parent ae1b9b7 commit f46e80b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
4 changes: 3 additions & 1 deletion slicereg/gui/view_models/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def on_left_mouse_drag(self, x1: int, y1: int, x2: int, y2: int):
scaled_dx = (x2 - x1) * scale
scaled_dy = (y2 - y1) * scale
self._model.move_section(x=scaled_dx, z=scaled_dy)
self._model.select_coord(i=x2, j=y2)

def on_mouse_move(self, x: int, y: int):
self._model.select_coord(i=x, j=y)

def on_right_mouse_drag(self, x1: int, y1: int, x2: int, y2: int):
scale = 1.
Expand Down
8 changes: 4 additions & 4 deletions tests/integration_tests/test_image_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ def test_impl():


@given("I have loaded a section")
def step_impl(model: AppModel):
model.load_section("myfile.ome.tiff")
def step_impl(sidebar):
sidebar.submit_load_section_from_file("myfile.ome.tiff")


@when("I indicate a section image coordinate")
def step_impl(model: AppModel):
model.select_coord(i=1, j=2)
def step_impl(slice_view):
slice_view.on_mouse_move(x=1, y=2)


@then("the coordinate's 2D position and 3D position should appear")
Expand Down
10 changes: 4 additions & 6 deletions tests/integration_tests/test_list_bgatlases.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
from pytest_bdd import scenario, when, then

from slicereg.gui.app_model import AppModel


@scenario("features/load_atlas.feature", "List Available Brainglobe Atlases")
def test_outlined():
...


@when("I refresh the brainglobe atlas list")
def step_impl(model: AppModel):
model.list_bgatlases()
def step_impl(sidebar):
sidebar.click_update_bgatlas_list_button()


@then("I see a list of bg-atlasapi's available atlases.")
def step_impl(model: AppModel, bg_atlases):
assert model.bgatlas_names == bg_atlases
def step_impl(sidebar, bg_atlases):
sidebar.bgatlas_names == bg_atlases
5 changes: 3 additions & 2 deletions tests/integration_tests/test_load_brainglobe_atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ def test_outlined():


@when("I load the 25um allen mouse atlas")
def load_atlas(model: AppModel):
model.load_bgatlas('allen_mouse_25um')
def load_atlas(sidebar):
sidebar.change_bgatlas_selection_dropdown('allen_mouse_25um')
sidebar.click_load_bgatlas_button()


@then("a 3D volume of the 25um allen reference atlas is loaded.")
Expand Down
5 changes: 3 additions & 2 deletions tests/integration_tests/test_load_imio_atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ def test_outlined():


@when("I load the mock.tiff atlas with 10um resolution")
def load_atlas(model):
model.load_atlas_from_file(filename='mock.tiff', resolution_um=10)
def load_atlas(sidebar):
sidebar.update_resolution_textbox(text="10")
sidebar.submit_load_atlas_from_file(filename='mock.tiff')


@then("a 3D volume of the atlas appears onscreen")
Expand Down
8 changes: 5 additions & 3 deletions tests/integration_tests/test_load_slice_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ def no_sections_loaded(model: AppModel):


@given("An atlas has been loaded")
def atlas_is_loaded(model: AppModel):
def atlas_is_loaded(sidebar, model):
sidebar.change_bgatlas_selection_dropdown("allen_mouse_25um")
sidebar.click_load_bgatlas_button()
assert model.atlas_volume is not None


@when("I load the file")
def load_file(model: AppModel, filename: str):
model.load_section(filename=filename)
def load_file(sidebar, filename: str):
sidebar.submit_load_section_from_file(filename=filename)


@then("I should see the slice image onscreen in 3D")
Expand Down

0 comments on commit f46e80b

Please sign in to comment.