I am writing test cases for an API that I have written using Django. I am calling that API in my test and then analysing the response, something like this:
from django.test import Client, TestCase
class MyTest(TestCase):
fixtures = ['model1.json', 'model2.json']
def test_some_case(self):
client = Client()
request_data = {
'path': '/internal/api/v1/some-url',
'data': {"key": "value"},
'content_type': "application/json"
}
response = client.post(**request_data)
assert response.status_code is not None
The API call (some-url) gets a redis client and creates an entry something like this:
client = MyRedis().get_redis_client()
client.setex(name=some_id, value=some_value,
time=some_expiry_time)
But as soon as I get the client, the test cases would keep running indefinitely, even after it has passed. If I comment out all code related to Redis in the API implementation, then the test runs as expected. This is a screenshot from IDE:
This is causing my test time-out during during deployments.