Changeset 5527


Ignore:
Timestamp:
27/07/09 22:09:17 (10 years ago)
Author:
pjkersha
Message:

Working soap unit test with UrlLib2SOAPClient.

Location:
TI12-security/trunk/python
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.common/ndg/security/common/soap/client.py

    r5526 r5527  
    3232                                         "requests and responses") 
    3333      
    34     def makeRequest(self, soapRequest): 
     34    def send(self, soapRequest): 
    3535        raise NotImplementedError() 
    3636 
    3737 
    3838class _SoapIOBase(object): 
     39    """Base class for request and response classes""" 
     40     
    3941    def __init__(self): 
    4042        self.__envelope = None 
     
    6163        self.__envelope = None 
    6264 
    63     url = property(fget=_getUrl, fset=_setUrl, doc="URL of SOAP endpoint") 
    64  
    6565    def _getUrl(self): 
    6666        return self.__url 
     
    7171                            '%r' % (basestring, type(value))) 
    7272        self.__url = value 
     73 
     74    url = property(fget=_getUrl, fset=_setUrl, doc="URL of SOAP endpoint") 
    7375 
    7476    
     
    8688    """Interface for UrlLib2 based SOAP Responses""" 
    8789    def __init__(self): 
    88         self.__fileobject 
     90        self.__fileobject = None 
     91 
     92    def _getFileobject(self): 
     93        return self.__fileobject 
    8994 
    9095    fileobject = property(fget=_getFileobject, 
    9196                          doc="urllib2 file object returned from request") 
    92  
    93     def getFileobject(self): 
    94         return self.__fileobject 
    9597 
    9698     
     
    132134                                  "opener(s) for handling requests") 
    133135     
    134     def makeRequest(self, soapRequest): 
     136    def send(self, soapRequest): 
    135137        """Make a request to the given URL with a SOAP Request object""" 
    136138         
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/unit/soap/test_soap.py

    r5526 r5527  
     1#!/usr/bin/env python 
    12"""SOAP module unit test module 
    23 
     
    1617from cStringIO import StringIO 
    1718import paste.fixture 
    18 from urllib2 import HTTPHandler 
     19from urllib2 import HTTPHandler, URLError 
    1920 
    2021from ndg.security.common.soap.etree import SOAPEnvelope 
    21 from ndg.security.common.soap.client import UrlLib2SOAPClient 
     22from ndg.security.common.soap.client import UrlLib2SOAPClient, \ 
     23    UrlLib2SOAPRequest 
    2224 
    2325class SOAPBindingMiddleware(object): 
     
    2527     
    2628    def __call__(self, environ, start_response): 
     29        requestFile = environ['wsgi.input'] 
     30         
     31        print("Server received request from client:\n\n%s" %  
     32              requestFile.read()) 
     33         
    2734        soapResponse = SOAPEnvelope() 
    2835        soapResponse.create() 
     
    8390         
    8491        # ElementTree based envelope class 
    85         client.envelopeClass = SOAPEnvelope 
     92        client.responseEnvelopeClass = SOAPEnvelope 
    8693         
    8794        request = UrlLib2SOAPRequest() 
     
    8996        request.envelope = SOAPEnvelope() 
    9097        request.envelope.create() 
    91         request = client.soapClass() 
    92         request.create() 
    9398         
    9499        client.openerDirector.add_handler(HTTPHandler()) 
    95         response = client.makeRequest(request) 
     100        try: 
     101            response = client.send(request) 
     102        except URLError, e: 
     103            self.fail("soap_server.py must be running for this test") 
     104         
     105        print("Response from server:\n\n%s" % response.envelope.serialize()) 
    96106 
    97107if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.