File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ class OperationProxy(object):
1313 def __init__ (self , service_proxy , operation_name ):
1414 self ._proxy = service_proxy
1515 self ._op_name = operation_name
16+ try :
17+ signature = str (self ._proxy ._binding ._operations [operation_name ])
18+ self .__doc__ = signature
19+ except :
20+ self .__doc__ = 'OperationProxy for %s' % operation_name
1621
1722 def __call__ (self , * args , ** kwargs ):
1823 """Call the operation with the given args and kwargs.
@@ -66,6 +71,13 @@ def __getitem__(self, key):
6671 except ValueError :
6772 raise AttributeError ('Service has no operation %r' % key )
6873 return OperationProxy (self , key )
74+
75+ def __dir__ (self ):
76+ """ Return the names of the operations. """
77+ return list (dir (super (ServiceProxy , self ))
78+ + list (self .__dict__ )
79+ + list (self ._binding .port_type .operations ))
80+ # using list() on the dicts for Python 3 compatibility
6981
7082
7183class Factory (object ):
Original file line number Diff line number Diff line change @@ -43,6 +43,20 @@ def test_service_proxy_non_existing():
4343 assert client_obj .service .NonExisting
4444
4545
46+ def test_service_proxy_dir_operations ():
47+ client_obj = client .Client ('tests/wsdl_files/soap.wsdl' )
48+ operations = [op for op in dir (client_obj .service ) if not op .startswith ('_' )]
49+ assert set (operations ) == set (['GetLastTradePrice' , 'GetLastTradePriceNoOutput' ])
50+
51+
52+ def test_operation_proxy_doc ():
53+ client_obj = client .Client ('tests/wsdl_files/soap.wsdl' )
54+ assert (client_obj .service .GetLastTradePrice .__doc__
55+ == 'GetLastTradePrice(tickerSymbol: xsd:string, '
56+ 'account: ns0:account, '
57+ 'country: ns0:country) -> price: xsd:float' )
58+
59+
4660def test_open_from_file_object ():
4761 with open ('tests/wsdl_files/soap_transport_err.wsdl' , 'rb' ) as fh :
4862 client_obj = client .Client (fh )
You can’t perform that action at this time.
0 commit comments