|
| 1 | +# Copyright (C) 2025 Robotec.AI |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +from rai.messages import HumanMultimodalMessage |
| 17 | + |
| 18 | + |
| 19 | +class TestMultimodalMessage: |
| 20 | + """Test the MultimodalMessage class and expected behaviors.""" |
| 21 | + |
| 22 | + def test_human_multimodal_message_text_simple(self): |
| 23 | + """Test text() method with simple text content.""" |
| 24 | + msg = HumanMultimodalMessage(content="Hello world") |
| 25 | + assert msg.text() == "Hello world" |
| 26 | + assert isinstance(msg.text(), str) |
| 27 | + |
| 28 | + def test_human_multimodal_message_text_with_images(self): |
| 29 | + """Test text() method with text and images.""" |
| 30 | + # Use a small valid base64 image (1x1 pixel PNG) |
| 31 | + valid_base64_image = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==" |
| 32 | + msg = HumanMultimodalMessage( |
| 33 | + content="Look at this image", images=[valid_base64_image] |
| 34 | + ) |
| 35 | + assert msg.text() == "Look at this image" |
| 36 | + # Should only return text type blocks, not image content |
| 37 | + assert valid_base64_image not in msg.text() |
0 commit comments