[Answered ]-How to test methods in models.py related to filters in django using pytest?

1👍

You can prepopulate data in Database, For better understanding, you can follow this link.

And then simply test your method shown below:

 class TestOrderModelMethods:
       def test_get_order_from_status(self):
                   assertQuerysetEqual(
                   Order.get_order_from_status(params='waiting', queryset=Order.objects.all()),
                   Order.objects.filter(status='waiting'),
                   ordered=False)
👤Hetvi

Leave a comment