Testing Spyne application

我的未来我决定 提交于 2019-12-01 13:26:35

问题


What is the best practice to test Spyne application. Does it have test client like Django or Flask. I dont like idea to start wsgi server to test my application.

Here is my flask+spyne example https://github.com/satyrius/flask-spyne-example


回答1:


For testing, we have the NullServer: http://spyne.io/docs/2.10/reference/server.html?highlight=nullserver#spyne.server.null.NullServer

It implements something close to the suds interface. Here's an example:

>>> app = Application(...)
>>> null = NullServer(app, ostr=False)
>>> print list(null.service.say_hello('Dave', 5)) 
[u'Hello, Dave', u'Hello, Dave', u'Hello, Dave', u'Hello, Dave', u'Hello, Dave']

Here's a fully working example: https://gist.github.com/7014099




回答2:


I suggest HttpClient from spyne.client.http or Client from suds.client.

Simple to work:

c = HttpClient('http://localhost:8000/', application)

u = c.factory.create("User")

u.user_name = 'dave'
u.first_name = 'david'

retval = c.service.add_user(u)

Ref.: spyne_client.



来源:https://stackoverflow.com/questions/19383937/testing-spyne-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!