我试图在django测试中创建虚拟redis。我的tests.py如下所示
class TestInitiatePositive(SimpleTestCase):
databases = '__all__'
def setUp(self):
pass
@responses.activate
def test_initiate_payment(self):
self.credentials = {
'username': '*****',
'password': '*****'
}
User.objects.create_user(**self.credentials)
self.client.login(username='*****',password='*****')
abc.objects.create(user_id_id ='1',nick_name = 'KONTO', access_token ='eyJ0eXAiOiJ')
response = self.client.post('/hello/initiate/',
data={"from": "*****", "to": "*****"})
self.assertContains(response, 'dummyUrl', status_code=200)
self.assertTemplateUsed(response, 'hello/redirecting.html')
一旦数据被插入表,模型信号就会被触发,celery 将从模型信号中提取任务并将其插入redis
@receiver(post_save, sender=access_tokens)
def access_token_added(sender, instance, created,**kwargs):
if created:
accessToken.delay(x)
我得到以下错误
Error 60 connecting to****:6379. Operation timed out.
我需要创建虚拟redis来完成这个测试用例。
暂无答案!
目前还没有任何答案,快来回答吧!