Skip to content

Commit 06eb32d

Browse files
committed
fix tests for flake8
Signed-off-by: Chris Snow <[email protected]>
1 parent 8899156 commit 06eb32d

File tree

10 files changed

+248
-96
lines changed

10 files changed

+248
-96
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
install:
4848
- pip3 install flake8 # TODO: install 'flake8-docstrings'
4949
script:
50-
- flake8 bin/ hpecp/ # TODO: add docstring 'flake8 --docstring-convention numpy hpecp/ bin/ tests/'
50+
- flake8 bin/ hpecp/ tests/ # TODO: add docstring 'flake8 --docstring-convention numpy hpecp/ bin/ tests/'
5151
- stage: format
5252
name: "Check code formatting"
5353
python: 3.8

tests/cli/cli_test.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
import requests
2828
from mock import patch
2929

30-
sys.path.insert(0, os.path.abspath("../../"))
31-
from bin import cli
32-
3330

3431
class MockResponse:
3532
def __init__(
@@ -66,7 +63,9 @@ def mocked_requests_post(*args, **kwargs):
6663
json_data={},
6764
status_code=200,
6865
headers={
69-
"location": "/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
66+
"location": (
67+
"/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
68+
)
7069
},
7170
)
7271
raise RuntimeError("Unhandle POST request: " + args[0])
@@ -157,4 +156,3 @@ def test_k8scluster_list(self, mock_post, mock_get):
157156

158157
hpecp = self.cli.CLI()
159158
hpecp.k8scluster.list()
160-

tests/cli/k8s_cluster_test.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@
1919
# OTHER DEALINGS IN THE SOFTWARE.
2020

2121
from unittest import TestCase
22-
from mock import Mock, patch, mock_open
22+
from mock import patch
2323

2424
from textwrap import dedent
2525
import sys
2626
import tempfile
2727
import os
28-
import json
2928
import requests
30-
from requests.exceptions import RequestException
3129

3230
sys.path.insert(0, os.path.abspath("../../"))
33-
from bin import cli
31+
from bin import cli # noqa: E402
3432

3533

3634
class MockResponse:
@@ -68,7 +66,9 @@ def mocked_requests_post(*args, **kwargs):
6866
json_data={},
6967
status_code=200,
7068
headers={
71-
"location": "/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
69+
"location": (
70+
"/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
71+
)
7272
},
7373
)
7474
raise RuntimeError("Unhandle POST request: " + args[0])
@@ -90,31 +90,46 @@ def mocked_requests_get(*args, **kwargs):
9090
"1.14.10": {
9191
"_version": "1.0",
9292
"min_upgrade_version": "1.13.0",
93-
"relnote_url": "https://v1-14.docs.kubernetes.io/docs/setup/release/notes/",
93+
"relnote_url": (
94+
"https://v1-14.docs.kubernetes.io/docs/setup"
95+
"/release/notes/"
96+
),
9497
"hpecsi": "1.14",
9598
},
9699
"1.15.7": {
97100
"_version": "1.0",
98101
"min_upgrade_version": "1.14.0",
99-
"relnote_url": "https://v1-15.docs.kubernetes.io/docs/setup/release/notes/",
102+
"relnote_url": (
103+
"https://v1-15.docs.kubernetes.io/docs/setup"
104+
"/release/notes/"
105+
),
100106
"hpecsi": "1.15",
101107
},
102108
"1.16.4": {
103109
"_version": "1.0",
104110
"min_upgrade_version": "1.15.0",
105-
"relnote_url": "https://v1-16.docs.kubernetes.io/docs/setup/release/notes/",
111+
"relnote_url": (
112+
"https://v1-16.docs.kubernetes.io/docs/setup"
113+
"/release/notes/"
114+
),
106115
"hpecsi": "1.16",
107116
},
108117
"1.17.0": {
109118
"_version": "1.0",
110119
"min_upgrade_version": "1.16.0",
111-
"relnote_url": "https://v1-17.docs.kubernetes.io/docs/setup/release/notes/",
120+
"relnote_url": (
121+
"https://v1-17.docs.kubernetes.io/docs/setup"
122+
"/release/notes/"
123+
),
112124
"hpecsi": "1.17",
113125
},
114126
"1.18.0": {
115127
"_version": "1.0",
116128
"min_upgrade_version": "1.17.0",
117-
"relnote_url": "https://kubernetes.io/docs/setup/release/notes/",
129+
"relnote_url": (
130+
"https://kubernetes.io/docs/setup"
131+
"/release/notes/"
132+
),
118133
"hpecsi": "1.18",
119134
},
120135
},

tests/library/client_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@
1919
# OTHER DEALINGS IN THE SOFTWARE.
2020

2121
from unittest import TestCase
22-
from mock import Mock, patch, mock_open
22+
from mock import patch
2323

2424
from textwrap import dedent
25-
import sys
2625
import tempfile
27-
import os
28-
import json
2926
import requests
30-
from requests.exceptions import RequestException
3127
from hpecp import ContainerPlatformClient
3228

3329

@@ -98,7 +94,9 @@ def mocked_requests_post(*args, **kwargs):
9894
json_data={},
9995
status_code=200,
10096
headers={
101-
"location": "/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
97+
"location": (
98+
"/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
99+
)
102100
},
103101
)
104102
raise RuntimeError("Unhandle POST request: " + args[0])
@@ -135,7 +133,9 @@ def mocked_requests_post_ssl(*args, **kwargs):
135133
json_data={},
136134
status_code=200,
137135
headers={
138-
"location": "/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
136+
"location": (
137+
"/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
138+
)
139139
},
140140
)
141141
raise RuntimeError("Unhandle POST request: " + args[0])

tests/library/config_test.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@
1919
# OTHER DEALINGS IN THE SOFTWARE.
2020

2121
from unittest import TestCase
22-
from mock import Mock, patch
22+
from mock import patch
2323

24-
import sys
25-
import tempfile
26-
import os
27-
import json
2824
import requests
29-
from requests.exceptions import RequestException
3025
from hpecp import ContainerPlatformClient
3126

3227

@@ -63,15 +58,19 @@ def mocked_requests_post(*args, **kwargs):
6358
json_data={},
6459
status_code=200,
6560
headers={
66-
"location": "/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
61+
"location": (
62+
"/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
63+
)
6764
},
6865
)
6966
elif args[0] == "https://127.0.0.1:8080/api/v2/config/auth":
7067
return MockResponse(
7168
json_data={},
7269
status_code=200,
7370
headers={
74-
"location": "/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
71+
"location": (
72+
"/api/v1/session/df1bfacb-xxxx-xxxx-xxxx-c8f57d8f3c71"
73+
)
7574
},
7675
)
7776
raise RuntimeError("Unhandle POST request: " + args[0])
@@ -94,7 +93,10 @@ def test_epic_tenant_list(self, mock_post):
9493
"bind_pwd": "5ambaPwd@",
9594
"user_attribute": "sAMAccountName",
9695
"bind_type": "search_bind",
97-
"bind_dn": "cn=Administrator,CN=Users,DC=samdom,DC=example,DC=com",
96+
"bind_dn": (
97+
"cn=Administrator,CN=Users,DC=samdom"
98+
",DC=example,DC=com"
99+
),
98100
"host": "1.1.1.1",
99101
"security_protocol": "ldaps",
100102
"base_dn": "CN=Users,DC=samdom,DC=example,DC=com",

0 commit comments

Comments
 (0)