Skip to content

Commit

Permalink
update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
djdameln committed Jan 21, 2025
1 parent 8e40838 commit 00cd481
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/unit/test_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,17 @@ class PointsPositionsValidatorTest:
"""Tests for the validator of the `positions` field in PointsCategories.Category."""

@staticmethod
def test_empty_positions():
def test_empty_positions_list():
"""Test that an empty list of positions is allowed."""
obj = PointsCategories.Category(positions=[])
assert obj.positions == [] # Should allow empty list

@staticmethod
def test_empty_positions_tuple():
"""Test that an empty list of positions is allowed."""
obj = PointsCategories.Category(positions=())
assert obj.positions == [] # Should allow empty list

@staticmethod
def test_none_positions():
"""Test that None is allowed and converted to an empty list."""
Expand Down Expand Up @@ -300,3 +306,19 @@ def test_num_positions_not_same_as_num_labels():
ValueError, match="number of positions should be equal to the number of labels"
):
PointsCategories.Category(labels=labels, positions=positions)

@staticmethod
def test_positions_allowed_with_empty_labels():
"""Test that the the number of coordinates check is skipped when labels is empty."""
labels = [] # no labels
positions = [1.0, 2.0, 3.0, 4.0] # 2 positions
obj = PointsCategories.Category(labels=labels, positions=positions)
assert obj

@staticmethod
def test_labels_allowed_with_empty_positions():
"""Test that the the number of coordinates check is skipped when positions is empty."""
labels = ["p1", "p2", "p3"] # 3 labels
positions = [] # no positions
obj = PointsCategories.Category(labels=labels, positions=positions)
assert obj

0 comments on commit 00cd481

Please sign in to comment.