Hello,
I'm testing REST APIs with rest_framework.test.APITestCase, using their client for making requests and model_mommy for creating objects in the setUp() method.
The general working is quite simple: the view is supposed to fetch a User and an object, and assign permissions for the former to the latter by means of django-guardian's assign_perm; the test creates a user and a group in the setUp method, then the actual test performs a POST passing their pk's as payload.
The issue I'm seeing, is that when the User.objects.filter(pk__in=people_ids) instruction is executed, the value I see in the debugger is that of an empty queryset, while if I type the exact same line in a console connected to the same session as the debugger I see the actual value being found.
Then the view gets to the assign_perm instruction, and it crashes with an IndexError: list index out of range error on the first evaluation of the queryset itself, which happens on the for loop at line 247 in the file core.py of the django-guardian library.
Is there something obvious that I should be looking at, because I really cannot wrap my head around this.
Thanks,
Michele