def test_file_edit_observation_new_file():
    """Test behavior when editing a new file."""
    obs = FileEditObservation(
        path='/test/new_file.txt',
        prev_exist=False,
        old_content='',
        new_content='Hello\nWorld\n',
        impl_source=FileEditSource.LLM_BASED_EDIT,
        content='',  # Initial content is old_content (empty for new file)
    )

    assert obs.prev_exist is False
    assert obs.old_content == ''
    assert (
        str(obs)
        == '[New file /test/new_file.txt is created with the provided content.]\n'
    )

    # Test that trying to visualize diff for a new file works
    diff = obs.visualize_diff()
    assert diff is not None
Test behavior when editing a new file.
tests/unit/test_file_edit_observation.py