"""Tests for Delete Value node."""

import pytest

from fw_nodes_core.nodes.delete_value import DeleteValueNode, DeleteValueOutput


@pytest.mark.asyncio
async def test_delete_existing_key(mock_context):
    """Test deleting a key that exists."""
    mock_context._data_store["temp"] = "value"
    node = DeleteValueNode()

    result = await node.execute({"key": "temp"}, mock_context)

    assert isinstance(result, DeleteValueOutput)
    assert result.key == "temp"
    assert result.existed is True
    assert "temp" not in mock_context._data_store


@pytest.mark.asyncio
async def test_delete_nonexistent_key(mock_context):
    """Test deleting a key that doesn't exist."""
    node = DeleteValueNode()

    result = await node.execute({"key": "nonexistent"}, mock_context)

    assert result.key == "nonexistent"
    assert result.existed is False
