Closed karpikpl closed 7 months ago
Unless I'm missing something in my code, in order to test Service Bus trigger functions, ServiceBusMessage
needs to be mocked?
from unittest.mock import Mock
import azure.functions as func
def test_your_function():
mock_msg = Mock(spec=func.ServiceBusMessage)
mock_msg.get_body.return_value = b"Your mock message body"
# Call your Azure function
result = your_function(mock_msg)
I'm wondering why HTTP Request has constructor but ServiceBusMessage
doesn't?
Is your question related to a specific version? If so, please specify: no
What binding does your question apply to, if any? (e.g. Blob Trigger, Event Hub Binding, etc)
ServiceBus
Question
How to create ServiceBusMessage in unit tests? Could you add examples for unit testing bindings other than http?
I'm getting "does not accept parameters" error when I try to create the ServiceBusMessage.