示例#1
0
def _test_type(cls, inst):
    # silence bogus warnings
    from spyne.util import appreg; appreg.applications.clear()

    class SomeService(ServiceBase):
        @rpc(_returns=cls, _body_style='bare')
        def some_call(ctx):
            return inst

    prot = HtmlForm(cloth=T_TEST)
    app = Application([SomeService], 'some_ns', out_protocol=prot)

    null = NullServer(app, ostr=True)

    ret = ''.join(null.service.some_call())
    try:
        elt = html.fromstring(ret)
    except:
        print(ret)
        raise

    show(elt, stdout=False)
    elt = elt.xpath('//form')[0]  # get the form tag inside the body tag
    elt = strip_ns(elt)  # get rid of namespaces to simplify xpaths in tests

    print(etree.tostring(elt, pretty_print=True))

    return elt
示例#2
0
def _test_type(cls, inst, prot_cls=HtmlFormTable):
    from spyne.util import appreg; appreg._applications.clear()

    class SomeService(ServiceBase):
        @rpc(_returns=cls, _body_style='bare')
        def some_call(ctx):
            return inst

    prot = prot_cls(cloth=T_TEST, doctype='<!DOCTYPE html>')
    app = Application([SomeService], 'some_ns', out_protocol=prot)

    null = NullServer(app, ostr=True)

    ret = ''.join(null.service.some_call())
    try:
        elt = html.fromstring(ret)
    except:
        print(ret)
        raise

    show(elt)
    elt = elt.xpath('//form')[0]
    elt = strip_ns(elt)  # get rid of namespaces to simplify xpaths in tests

    print(R("========== fragment =========="))
    print(etree.tostring(elt, pretty_print=True))
    print(R("========== fragment =========="))

    return elt
示例#3
0
def _test_type(cls, inst):
    from spyne.util import appreg
    appreg._applications.clear()

    class SomeService(ServiceBase):
        @rpc(_returns=cls, _body_style='bare')
        def some_call(ctx):
            return inst

    prot = HtmlForm(cloth=T_TEST)
    app = Application([SomeService], 'some_ns', out_protocol=prot)

    null = NullServer(app, ostr=True)

    ret = ''.join(null.service.some_call())
    try:
        elt = html.fromstring(ret)
    except:
        print(ret)
        raise

    show(elt, stdout=False)
    elt = elt.xpath('//*[@spyne]')[0][
        0]  # get the form tag inside the body tag
    elt = strip_ns(elt)  # get rid of namespaces to simplify xpaths in tests

    print(etree.tostring(elt, pretty_print=True))

    return elt
示例#4
0
def _test_type(cls, inst):
    from spyne.util import appreg; appreg._applications.clear()

    class SomeService(ServiceBase):
        @rpc(_returns=cls, _body_style='bare')
        def some_call(ctx):
            return inst

    prot = HtmlFormTable(cloth=T_TEST)
    app = Application([SomeService], 'some_ns', out_protocol=prot)

    null = NullServer(app, ostr=True)

    elt = etree.fromstring(''.join(null.service.some_call()))
    show(elt, stdout=False)
    elt = elt.xpath('//*[@spyne]')[0]
    elt = strip_ns(elt)  # get rid of namespaces to simplify xpaths in tests

    print(etree.tostring(elt, pretty_print=True))

    return elt