Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
647 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...