Thank you very much!
I'll try that!
Best regards,
Carsten
Am 11.11.20 um 02:28 schrieb David Nugent:
> Make your own request.
>
> I don't see the need here but incase I'm missing something: request is just a HTTPRequest <
https://docs.djangoproject.com/en/3.1/ref/request-response/#httprequest-objects> instance. You can instantiate it like any other python class. The only downside is that the request you manufacture won't have middleware applied or in fact anything else that is populated and processed before it gets to your handler (headers, method, parsed url parts, content and so on).
>
> This may not actually be an issue in test scenarios, depending on your need, and in this case on the backing store <
https://docs.djangoproject.com/en/3.1/ref/contrib/messages/#storage-backends> used by the messages framework. If it is set to session, then you'll need to obtain a session from the client and stick it onto your request object if you want that to persist through your subsequent test requests.
>
> HTH /d
>
>> On 10 Nov 2020, at 18:41, Carsten Fuchs <
carste...@cafu.de <mailto:
carste...@cafu.de>> wrote:
>>
>> Dear group,
>>
>> in my tests I would like to test the processing of messages in the view.
>>
>> For example:
>>
>> def test_is_message_properly_handled(self):
>> # The problem: We have no `request` here!
>>
messages.info <
http://messages.info>(request, 'Hello')