示例#1
0
def test_get_classification_no_classification():
    """ Test attempting to get the classification element when none is set. """
    inst = MemoryDetectionElement(0)
    with pytest.raises(NoDetectionError,
                       match="Missing or empty classification for in-memory "
                       "detection with UUID 0"):
        inst.get_classification()
示例#2
0
def test_get_classification_empty_classification():
    """ Test attempting to get the classification element when it is empty. """
    c_elem = mock.MagicMock(spec_set=ClassificationElement)
    # Simulate an empty ClassificationElement
    c_elem.has_classifications.return_value = False

    inst = MemoryDetectionElement(0)
    inst._classification = c_elem
    with pytest.raises(NoDetectionError,
                       match="Missing or empty classification for in-memory "
                       "detection with UUID 0"):
        inst.get_classification()
示例#3
0
def test_get_classification():
    """ Test successfully getting the detection classification element. """
    c_elem = mock.MagicMock(spec_set=ClassificationElement)
    # Simulate a populated ClassificationElement
    c_elem.has_classifications.return_value = True
    inst = MemoryDetectionElement(0)
    inst._classification = c_elem
    assert inst.get_classification() == c_elem