Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
refactor tests slightly.
  • Loading branch information
maliagehan committed Mar 29, 2024
1 parent 239379f commit 6843253
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 33 deletions.
7 changes: 1 addition & 6 deletions tests/test_napari_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from plantcv.annotate import napari_classes


def test_napari_classes(make_napari_viewer, qtbot):
def test_napari_classes(make_napari_viewer):
"""Test for PlantCV.Annotate"""
# Read in test data
viewer = make_napari_viewer()
Expand All @@ -15,9 +15,4 @@ def test_napari_classes(make_napari_viewer, qtbot):
face_color="red", size=30)
keys = napari_classes(viewer)

def check_keys():
assert keys != []

qtbot.waitUntil(check_keys, timeout=60_000)

assert keys == ['total', 'test']
7 changes: 1 addition & 6 deletions tests/test_napari_label_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from plantcv.plantcv import readimage


def test_napari_label_classes_gray(make_napari_viewer, qtbot, test_data):
def test_napari_label_classes_gray(make_napari_viewer, test_data):
"""Test for PlantCV.Annotate"""
# Read in test data
img, _, _ = readimage(test_data.kmeans_seed_gray_img)
Expand All @@ -13,9 +13,4 @@ def test_napari_label_classes_gray(make_napari_viewer, qtbot, test_data):
viewer.add_points(np.array(coor), symbol="o", name='background',
face_color="red", size=1)

def check_open():
assert np.shape(viewer.layers['background'].data) != (0, 2)

qtbot.waitUntil(check_open, timeout=60_000)

assert len(viewer.layers['background'].data) == 1
27 changes: 6 additions & 21 deletions tests/test_napari_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,41 @@
from plantcv.plantcv import readimage


def test_napari_open_rgb(make_napari_viewer, qtbot, test_data):
def test_napari_open_rgb(viewer_widget, test_data):
"""Test for PlantCV.Annotate"""
# Read in test data
img, _, _ = readimage(test_data.small_rgb_img)
viewer = make_napari_viewer()
viewer = viewer_widget
viewer = napari_open(img, viewer)
coor = [(25, 25), (50, 50)]
viewer.add_points(np.array(coor), symbol="o", name="total",
face_color="red", size=1)

def check_open():
assert np.shape(viewer.layers['total'].data) != (0, 2)

qtbot.waitUntil(check_open, timeout=60_000)

assert len(viewer.layers['total'].data) == 2


def test_napari_open_gray(make_napari_viewer,qtbot, test_data):
def test_napari_open_gray(viewer_widget, test_data):
"""Test for PlantCV.Annotate"""
# Read in test data
img, _, _ = readimage(test_data.kmeans_seed_gray_img)
viewer = make_napari_viewer()
viewer = viewer_widget
viewer = napari_open(img, viewer)
coor = [(25, 25), (50, 50)]
viewer.add_points(np.array(coor), symbol="o", name="total",
face_color="red", size=1)

def check_open():
assert np.shape(viewer.layers['total'].data) != (0, 2)

qtbot.waitUntil(check_open, timeout=60_000)

assert len(viewer.layers['total'].data) == 2


def test_napari_open_envi(make_napari_viewer,qtbot, test_data):
def test_napari_open_envi(viewer_widget, test_data):
"""Test for PlantCV.Annotate"""
# Read in test data
img = readimage(test_data.envi_sample_data, mode='envi')
img = img.array_data
viewer = make_napari_viewer()
viewer = viewer_widget
viewer = napari_open(img, viewer)
coor = [(25, 25), (50, 50)]
viewer.add_points(np.array(coor), symbol="o", name="total",
face_color="red", size=1)

def check_open():
assert np.shape(viewer.layers['total'].data) != (0, 2)

qtbot.waitUntil(check_open, timeout=60_000)

assert len(viewer.layers['total'].data) == 2

0 comments on commit 6843253

Please sign in to comment.