【问题标题】:How to test Soap Service on Django with Spyne with Zeep如何使用带有 Zeep 的 Spyne 在 Django 上测试 Soap 服务
【发布时间】:2021-04-11 09:33:02
【问题描述】:

我尝试在 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)

【问题讨论】:

    标签: django unit-testing soap serversocket zeep


    【解决方案1】:

    我已经解决了使用相同的服务器客户端,不需要像Zeep这样的其他客户端,只有一个Spyne的客户端。

    解决办法在这里:

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

    而且这个方法在这里与DJango完美集成:

    from spyne.client.django import DjangoTestClient
    

    【讨论】:

      猜你喜欢
      • 2015-09-21
      • 1970-01-01
      • 2022-08-16
      • 2021-04-13
      • 2012-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多