Example #1
0
def test_node_verify(mock_exists, mock_actual_perms, mock_actual_owner, mock_actual_group, atts):
    """Test Node's method verify."""
    # Test passing verification
    mock_exists.return_value = True
    node = Node(atts)
    node.actual_perms = None if 'perms' not in atts else atts['perms']
    node.actual_owner = None if 'owner' not in atts else atts['owner']
    node.actual_group = None if 'group' not in atts else atts['group']
    assert node.verify(False)

    # Test failing verification
    if atts['path']:
        # If there is no path, it's a stub and should always verify true.
        mock_exists.return_value = False
        mock_actual_perms.return_value = None
        mock_actual_owner.return_value = None
        mock_actual_group.return_value = None
        bad_node = Node(atts)
        assert not bad_node.verify(False)