问题描述
我尝试在 django 上使用 zeep 对 SOAP 服务进行测试(使用 Spyne),但总是需要运行 runserver,但需要在没有 runserver 的情况下执行,因为需要使用测试数据库而不是默认数据库。
我像这样使用:
def test_obtenerListaAcciones(self):
# get actions
# this server need to be up to work,but need to be execute test without work this.
wsdl = 'http://127.0.0.1:8000/soap/getactions/'
client = zeep.Client(wsdl=wsdl)
headerArr = {}
settings = Settings(strict=False,xml_huge_tree=True,extra_http_headers=headerArr,raw_response=True)
client = Client(wsdl,settings=settings)
action = self.test_create_actions()
requestData = {
}
res = client.service.getactions(**requestData)
解决方法
我已经解决了使用相同的服务器客户端,不需要使用其他像Zeep这样的客户端,只需要一个Spyne的客户端。
解决方案在这里:
https://github.com/arskom/spyne/blob/master/spyne/test/interop/test_django.py
这个方法与DJango完美结合:
from spyne.client.django import DjangoTestClient