Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
664 views
in Technique[技术] by (71.8m points)

unit testing - How to test Soap Service on Django with Spyne with Zeep

i trying to using zeep on django to make test to a SOAP service (using Spyne), but always need to be running a runserver, but need to be executed without runserver because need to using a test database not a default database.

i using like like this:

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I has solve using the same client of server that not need to use other like Zeep, only a client of Spyne.

the solution are here:

https://github.com/arskom/spyne/blob/master/spyne/test/interop/test_django.py

and this method is perfect integrated with DJango here:

from spyne.client.django import DjangoTestClient

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...