async def test_metadata_preservation(self):
        """Test that existing metadata is preserved when chunking."""
        # Create a large Python file with metadata
        chunk_size_limit = MAX_CHUNK_SIZE - METADATA_SIZE  # This is 7191
        threshold = chunk_size_limit + 100  # Just over the limit
        large_content = generate_large_code_content(threshold)

        # Create file with existing metadata
        file = CodeFileEntity(
            entity_id=str(uuid.uuid4()),
            breadcrumbs=[],
            source_name="test",
            name="test_with_metadata.py",
            file_id="meta123",
            size=len(large_content),
            path_in_repo="test_with_metadata.py",
            repo_name="test-repo",
            repo_owner="test-owner",
            url="https://example.com/test_with_metadata.py",
            content=large_content,
            language="python",
            metadata={"existing_key": "existing_value", "another_key": 42, "important_flag": True},
        )

        # Process with the real code chunker
        result = await code_file_chunker(file)

        # Verify chunking happened
        assert len(result) > 1

        # Verify original metadata is preserved in all chunks
        for chunk_file in result:
            assert chunk_file.metadata["existing_key"] == "existing_value"
            assert chunk_file.metadata["another_key"] == 42
            assert chunk_file.metadata["important_flag"] is True
Test that existing metadata is preserved when chunking.
backend/tests/unit/platform/transformers/test_code_file_chunker.py