Skip to content

Commit eaef8cf

Browse files
committed
Refactored test implementation to be compatible with PEP8
1 parent 094189c commit eaef8cf

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

tests/acos_base_action_test_case.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import yaml
44

55
from st2tests.base import BaseActionTestCase
6-
from urllib.parse import urlparse
76

87

98
class 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

tests/test_slb_service_group.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import json
22
import mock
3-
import re
43

54
from acos_base_action_test_case import ACOSBaseActionTestCase
65
from ax_action_runner import AXActionRunner
7-
from requests import Session
86
from urllib.parse import urlparse
97

108
RESP_SUCCESS = {'response': {'status': 'success'}}
@@ -243,7 +241,8 @@ def test_create_slb_service_group_for_acos(self, mock_session):
243241
"name": "test-slb-service-group",
244242
"protocol": "tcp",
245243
"health-check-disable": 0,
246-
"lb-method": "round-robin","stateless-auto-switch": 0
244+
"lb-method": "round-robin",
245+
"stateless-auto-switch": 0
247246
}
248247
}))
249248
self.assertEqual(self._sending_requests[0]['method'], 'POST')

0 commit comments

Comments
 (0)