33import yaml
44
55from st2tests .base import BaseActionTestCase
6- from urllib .parse import urlparse
76
87
98class ACOSBaseActionTestCase (BaseActionTestCase ):
@@ -39,18 +38,19 @@ def get_mock_session(self, resp_data):
3938 whether sending requests from each test have expected destination endpoint
4039 and expected parameters.
4140 """
41+ ACOS_API_AUTH_PATH = [
42+ '/services/rest/v2.1/?format=json&method=authenticate' ,
43+ '/axapi/v3/auth'
44+ ]
4245 self ._sending_requests = []
46+
4347 def _save_sending_request (api_url , method , params ):
4448 self ._sending_requests .append ({
4549 'url' : api_url ,
4650 'method' : method ,
4751 'params' : params ,
4852 })
4953
50- ACOS_API_AUTH_PATH = [
51- '/services/rest/v2.1/?format=json&method=authenticate' ,
52- '/axapi/v3/auth'
53- ]
5454 def _mock_sending_request (api_url , method , params ):
5555 mock_resp = mock .Mock ()
5656 if method == 'POST' and any ([x in api_url for x in ACOS_API_AUTH_PATH ]):
@@ -68,8 +68,10 @@ def _mock_sending_request(api_url, method, params):
6868
6969 def get_side_effect (api_url , ** kwargs ):
7070 return _mock_sending_request (api_url , 'GET' , kwargs )
71+
7172 def post_side_effect (api_url , ** kwargs ):
7273 return _mock_sending_request (api_url , 'POST' , kwargs )
74+
7375 def delete_side_effect (api_url , ** kwargs ):
7476 return _mock_sending_request (api_url , 'DELETE' , kwargs )
7577
0 commit comments