I am running into a strange issue where my get_queryset() method for my ViewSet is grabbing the correct results but one of the objects in the query gets dropped as it's being returned to my test case. I can't really post any code but I can display parts of the test that fail and some logs.
Has anyone ever encountered this problem?
Here is the print out of my model field names just before the return statement in get_queryset(self):
QUERYSET len: 3
QUERYSET should return: <QuerySet ['Test', 'Test', 'Test']>
The assertion in my TestCase after calling the viewset and storing the response in res
self.assertEqual(len(res.data), 3)
AssertionError: 2 != 3
I don't understand how the ViewSet's get_queryset() clearly shows that the length is 3, yet the response returned from the ViewSet only has 2 objects out of the 3 in it. I've also tested serializing the response.data and testing that length also shows up as 2 but should be 3. So confused. I hope this is enough info for someone to go off of.
Aucun commentaire:
Enregistrer un commentaire