I am trying to write some unit tests for an asynchronous method in my Django app. Essentially, when a user does a certain POST, this method is kicked off so the application doesn't hang. What I want to test is the ability to cancel this request as it is running (in this case via celery). The only problem with doing this is because Celery is running independent of the web application, it pushes the results to the real database, not the test database that is created by Django Unit Tests. So what I'm wondering is how would I be able to do something like
Results.objects.get(id=some_id)
and tell it to point to the actual database. I've already tried the following:
Results.objects.using('default').get(id=some_id)
Thinking that maybe this would solve the problem, but it didn't find the result (again because it was pushing the information to the actual database, not the test DB). I did some searching around and found this link: How do I run a unit test against the production database? but the answers on here say things like "You shouldn't test against production." I completely understand this is not good practice but I need to hit the live database. Everything is being run on a VM so it's all a test database anyways. Does anyone know of a way to hit the real database?
Thanks,