def test_has_detection_one_none_member(): """ Test that has_detections is false if at least one of the members is None. """ # Possible "valid" values. bbox = mock.MagicMock(spec_set=AxisAlignedBoundingBox) celem = mock.MagicMock(spec_set=ClassificationElement) celem.has_classifications.return_value = True inst = MemoryDetectionElement(0) inst._bbox = None inst._classification = celem assert inst.has_detection() is False inst._bbox = bbox inst._classification = None assert inst.has_detection() is False
def test_has_detection_none_members(): """ Test that has_detection is false when neither bbox nor classification are set. """ inst = MemoryDetectionElement(0) inst._bbox = inst._classification = None assert inst.has_detection() is False
def test_has_detection(): """ Test that has_detection is true for True-evaluating attributes """ inst = MemoryDetectionElement(0) inst._bbox = mock.MagicMock(spec=AxisAlignedBoundingBox) # Simulate having a non-empty element. inst._classification = mock.MagicMock(spec_set=ClassificationElement) inst._classification.has_classifications.return_value = True assert inst.has_detection() is True
def test_has_detection_empty_classification_element(): """ Test that when one or both attributes are false-evaluating but not None, has_detection returns false. """ bbox = mock.MagicMock(spec_set=AxisAlignedBoundingBox) celem = mock.MagicMock(spec_set=ClassificationElement) celem.has_classifications.return_value = False inst = MemoryDetectionElement(0) inst._bbox = bbox inst._classification = celem assert inst.has_detection() is False