async def run():
    stream_id_1 = "lRwCZlDbxWLd2BDP-1D_8n___o0f4ZkEdA"
    stream_id_2 = "12lruitZ3cecVY1_SKgKB3___omJ6uHodA"

    config = BdkConfigLoader.load_from_symphony_dir("config.yaml")

    async with SymphonyBdk(config) as bdk:
        message_service = bdk.messages()

        await message_service.send_message(stream_id_1, "<messageML>Hello, World!</messageML>")

        with open("/path/to/attachment1", "rb") as file1, \
                open("/path/to/attachment2", "rb") as file2:
            message = Message(content="<messageML>Hello, World!</messageML>", attachments=[file1, file2])
            await message_service.blast_message([stream_id_1, stream_id_2], message)

        with open("/path/to/attachment", "rb") as attachment, \
                open("/path/to/attachment-preview", "rb") as preview:
            message = Message(content="<messageML>Hello, World!</messageML>", attachments=[(attachment, preview)])
            await message_service.blast_message([stream_id_1, stream_id_2], message)

        async for m in await message_service.search_all_messages(MessageSearchQuery(text="some_text",
                                                                                    stream_id=stream_id_1)):
            logging.debug(m.message_id)

        logging.info("Obo example:")
        obo_auth_session = bdk.obo(username="******")
        async with bdk.obo_services(obo_auth_session) as obo_services:
            # Message ID can be retrieved by following guide here:
            # https://docs.developers.symphony.com/building-bots-on-symphony/datafeed/overview-of-streams
            await obo_services.messages().suppress_message("URL-Safe MessageID")
async def test_search_messages_with_stream_type_text_and_no_sid(
        mocked_api_client, message_service, stream_type):
    mocked_api_client.call_api.return_value = \
        get_deserialized_object_from_resource(V4MessageList, "message_response/list_messages.json")

    with pytest.raises(ValueError):
        await message_service.search_messages(
            MessageSearchQuery(text="some text", stream_type=stream_type))
async def test_search_messages_with_invalid_stream_type(
        mocked_api_client, message_service):
    mocked_api_client.call_api.return_value = \
        get_deserialized_object_from_resource(V4MessageList, "message_response/list_messages.json")

    with pytest.raises(ValueError):
        await message_service.search_messages(
            MessageSearchQuery(stream_type="invalid"))
async def test_search_messages_with_text_and_sid(mocked_api_client,
                                                 message_service):
    mocked_api_client.call_api.return_value = \
        get_deserialized_object_from_resource(V4MessageList, "message_response/list_messages.json")

    messages = await message_service.search_messages(
        MessageSearchQuery(text="some text", stream_id="sid"))
    assert len(messages) == 1
    assert messages[0].message_id == "test-message1"
async def test_search_messages_with_hashtag(mocked_api_client,
                                            message_service):
    mocked_api_client.call_api.return_value = \
        get_deserialized_object_from_resource(V4MessageList, "message_response/list_messages.json")

    messages = await message_service.search_messages(
        MessageSearchQuery(hashtag="tag"))
    assert len(messages) == 1
    assert messages[0].message_id == "test-message1"
async def test_search_all_messages(mocked_api_client, message_service):
    mocked_api_client.call_api.side_effect = \
        [get_deserialized_object_from_resource(V4MessageList, "message_response/list_messages.json"),
         V4MessageList(value=[])]
    chunk_size = 1

    message_generator = await message_service.search_all_messages(
        MessageSearchQuery(hashtag="tag"), chunk_size=chunk_size)
    messages = [m async for m in message_generator]
    assert len(messages) == 1
    assert messages[0].message_id == "test-message1"

    assert mocked_api_client.call_api.call_count == 2