I am trying to test the number of DB queries executed by an API in my Django application. So, I have a test case similar to the following:
class DatabaseQueriesTestCase(TestCase):
scan_uri = "something"
def test_API_1(self):
payload = {
'id': 12,
'name': "ABCD"
}
self.assertNumQueries(13, self.client.post, self.scan_uri, data=payload)
On running the test multiple times, some pass while others fail. Some fail
, saying one more query was run. Why is this happening? Is this a problem with assertNumQueries ??
Note: Using Redis cache in my application..