Skip to content

Commit e3975ce

Browse files
committed
sort imports
1 parent a7d72c9 commit e3975ce

15 files changed

+84
-72
lines changed

pre_push_verifications.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22

33
set -e
44

5+
isort --check-only tests/*.py bin/*.py
6+
57
black bin/ tests/ hpecp/
68

79
#flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
810
flake8 --exclude hpecp/role.py --docstring-convention numpy bin/ hpecp/
911

10-
tox -- tests/
12+
flake8 --ignore=D,E501 tests/catalog_test.py
13+
14+
tox -e py35 -- tests/
15+
16+
echo "********** FIXME: tox should test py27 as well **********"
1117

1218
# coverage causes some tests to fail on PY3 so test it (issues 93)
13-
coverage3 erase && coverage3 run --source hpecp,bin setup.py test && coverage3 report -m
19+
#coverage3 erase && coverage3 run --source hpecp,bin setup.py test && coverage3 report -m
20+
21+

setup.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ exclude = hpecp/role.py
1919

2020
[pycodestyle]
2121
max-line-length = 79
22+
23+
[isort]
24+
multi_line_output=3
25+
include_trailing_comma=True
26+
force_grid_wrap=0
27+
use_parentheses=True
28+
line_length=79
2229

2330

2431

tests/base_resource_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# OTHER DEALINGS IN THE SOFTWARE.
2020

2121
import unittest
22+
2223
from mock import MagicMock
2324

2425
from hpecp.base_resource import (

tests/base_test.py

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

2121
import abc
22+
import json
2223
import os
2324
import sys
2425
import tempfile
26+
import unittest
2527
from io import StringIO
2628
from textwrap import dedent
2729
from unittest import TestCase
28-
import json
29-
import unittest
30+
3031
import requests
3132
import six
3233
from mock import patch

tests/catalog_test.py

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

2121

22-
import os
23-
import sys
22+
import json
2423
import unittest
2524
from textwrap import dedent
26-
import json
27-
import yaml
2825

29-
import requests
26+
import yaml
3027
from mock import patch
3128

32-
from hpecp import ContainerPlatformClient
33-
from hpecp.exceptions import APIItemNotFoundException
34-
import tempfile
3529
from hpecp.base_resource import ResourceList
30+
from hpecp.exceptions import APIItemNotFoundException
3631

3732
from .base_test import BaseTestCase, MockResponse, get_client
38-
import six
39-
4033

4134
BaseTestCase.registerHttpPostHandler(
4235
url="https://127.0.0.1:8080/api/v1/catalog/99",
@@ -268,7 +261,7 @@ def test_get_catalog_id_format(self, mock_get, mock_post):
268261
@patch("requests.post", side_effect=BaseTestCase.httpPostHandlers)
269262
def test_get_catalog(self, mock_get, mock_post):
270263

271-
catalog = get_client().catalog.get("/api/v1/catalog/99")
264+
get_client().catalog.get("/api/v1/catalog/99")
272265

273266
with self.assertRaisesRegexp(
274267
APIItemNotFoundException,
@@ -402,8 +395,8 @@ def test_catalog_install_cli_with_catalog_id_not_found(
402395
self.assertTrue(
403396
stderr.endswith(expected_stderr),
404397
(
405-
"stderr = `{}`\n".format(stderr)
406-
+ "stderr does not end with `{}`".format(expected_stderr)
398+
"stderr = `{}`\n"
399+
"stderr does not end with `{}`".format(stderr, expected_stderr)
407400
),
408401
)
409402

@@ -422,7 +415,7 @@ def test_catalog_install_cli_success(self, mock_get, mock_post):
422415
# successful refresh should not output anything
423416
expected_stdout = ""
424417

425-
self.assertEqual(stdout, "")
418+
self.assertEqual(stdout, expected_stdout)
426419

427420

428421
class TestCatalogRefresh(BaseTestCase):
@@ -497,8 +490,8 @@ def test_catalog_refresh_cli_with_catalog_id_not_found(
497490
self.assertTrue(
498491
stderr.endswith(expected_stderr),
499492
(
500-
"stderr = `{}`\n".format(stderr)
501-
+ "stderr does not end with `{}`".format(expected_stderr)
493+
"stderr = `{}`\n"
494+
"stderr does not end with `{}`".format(stderr, expected_stderr)
502495
),
503496
)
504497

@@ -517,7 +510,7 @@ def test_catalog_refresh_cli_success(self, mock_get, mock_post):
517510
# successful refresh should not output anything
518511
expected_stdout = ""
519512

520-
self.assertEqual(stdout, "")
513+
self.assertEqual(stdout, expected_stdout)
521514

522515

523516
class TestCLIList(BaseTestCase):
@@ -534,11 +527,13 @@ def test_list_with_columns_and_table_output(self, mock_post, mock_get):
534527

535528
self.assertEqual(
536529
output,
537-
"+------------+--------------------------------------------------------------------------------+\n"
538-
+ "| label_name | label_description |\n"
539-
+ "+------------+--------------------------------------------------------------------------------+\n"
540-
+ "| Spark240 | Spark240 multirole with Jupyter Notebook, Jupyterhub with SSL and gateway node |\n"
541-
+ "+------------+--------------------------------------------------------------------------------+",
530+
(
531+
"+------------+--------------------------------------------------------------------------------+\n"
532+
"| label_name | label_description |\n"
533+
"+------------+--------------------------------------------------------------------------------+\n"
534+
"| Spark240 | Spark240 multirole with Jupyter Notebook, Jupyterhub with SSL and gateway node |\n"
535+
"+------------+--------------------------------------------------------------------------------+"
536+
),
542537
)
543538

544539
@patch("requests.post", side_effect=BaseTestCase.httpPostHandlers)

tests/cli_test.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1919
# OTHER DEALINGS IN THE SOFTWARE.
2020

21+
import json
2122
import os
2223
import sys
2324
import tempfile
@@ -27,15 +28,12 @@
2728
import requests
2829
import six
2930
from mock import mock, mock_open, patch
30-
from hpecp.cli import base
3131

32-
from .base_test import (
33-
BaseTestCase,
34-
MockResponse,
35-
session_mock_response as base_login_post_response,
36-
)
32+
from hpecp.cli import base
3733
from hpecp.gateway import Gateway
38-
import json
34+
35+
from .base_test import BaseTestCase, MockResponse
36+
from .base_test import session_mock_response as base_login_post_response
3937

4038
if six.PY2:
4139
from io import BytesIO as StringIO # noqa: F811

tests/client_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
# OTHER DEALINGS IN THE SOFTWARE.
2020

2121
import os
22+
import tempfile
23+
from textwrap import dedent
2224
from unittest import TestCase
23-
from mock import patch
2425

25-
from textwrap import dedent
26-
import tempfile
2726
import requests
27+
from mock import patch
28+
2829
from hpecp import ContainerPlatformClient, ContainerPlatformClientException
2930

3031

tests/config_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
# OTHER DEALINGS IN THE SOFTWARE.
2020

2121
from unittest import TestCase
22-
from mock import patch
2322

2423
import requests
24+
from mock import patch
25+
2526
from hpecp import ContainerPlatformClient
2627

2728

tests/gateway_test.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,21 @@
1818
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1919
# OTHER DEALINGS IN THE SOFTWARE.
2020

21+
import os
22+
import sys
23+
import tempfile
24+
from textwrap import dedent
2125
from unittest import TestCase
2226

2327
import requests
28+
import six
2429
from mock import Mock, patch
2530

26-
from hpecp import (
27-
APIItemNotFoundException,
28-
ContainerPlatformClient,
29-
)
31+
from hpecp import APIItemNotFoundException, ContainerPlatformClient
32+
from hpecp.exceptions import APIItemConflictException
3033
from hpecp.gateway import GatewayController, GatewayStatus
31-
from textwrap import dedent
32-
import tempfile
33-
import os
34-
import sys
35-
import six
3634

3735
from .base_test import BaseTestCase
38-
from hpecp.exceptions import APIItemConflictException
3936

4037
if six.PY2:
4138
from io import BytesIO as StringIO

tests/k8s_cluster_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,19 @@
1818
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1919
# OTHER DEALINGS IN THE SOFTWARE.
2020

21+
import base64
22+
import json
2123
import os
2224
import sys
2325
import tempfile
2426
from io import StringIO
2527
from textwrap import dedent
2628
from unittest import TestCase
27-
import json
2829

2930
import requests
3031
import six
3132
from mock import patch
3233

33-
from .base_test import BaseTestCase, session_mock_response
34-
3534
from hpecp import (
3635
APIException,
3736
APIItemNotFoundException,
@@ -42,7 +41,8 @@
4241
K8sClusterHostConfig,
4342
K8sClusterStatus,
4443
)
45-
import base64
44+
45+
from .base_test import BaseTestCase, session_mock_response
4646

4747
if six.PY2:
4848
from io import BytesIO as StringIO # noqa: F811

tests/k8s_worker_test.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
import json
2+
import os
3+
import sys
4+
import tempfile
15
from unittest import TestCase
6+
27
import requests
3-
from mock import patch, MagicMock
4-
import sys
5-
import os
6-
import json
8+
from mock import MagicMock, patch
79

8-
from hpecp.cli import base
910
from hpecp import ContainerPlatformClient
10-
from hpecp.k8s_worker import K8sWorkerController, WorkerK8sStatus, WorkerK8s
11+
from hpecp.cli import base
1112
from hpecp.exceptions import APIItemConflictException, APIItemNotFoundException
12-
from .base_test import session_mock_response, BaseTestCase
13-
import tempfile
13+
from hpecp.k8s_worker import K8sWorkerController, WorkerK8s, WorkerK8sStatus
14+
15+
from .base_test import BaseTestCase, session_mock_response
1416

1517
try:
1618
from imp import reload

tests/license_test.py

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

2121

22+
import json
2223
import os
2324
import sys
25+
import tempfile
2426
import unittest
2527
from textwrap import dedent
26-
import json
27-
import yaml
2828

2929
import requests
30+
import six
31+
import yaml
3032
from mock import patch
3133

3234
from hpecp import ContainerPlatformClient
33-
from hpecp.exceptions import APIItemNotFoundException
34-
import tempfile
3535
from hpecp.base_resource import ResourceList
36+
from hpecp.exceptions import APIItemNotFoundException
3637

3738
from .base_test import BaseTestCase, MockResponse, mocked_login_post
38-
import six
3939

4040

4141
class TestCLI(BaseTestCase):

tests/lock_test.py

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

2121

22+
import json
2223
import os
2324
import sys
25+
import tempfile
2426
import unittest
2527
from textwrap import dedent
26-
import json
27-
import yaml
2828

2929
import requests
30+
import six
31+
import yaml
3032
from mock import patch
3133

3234
from hpecp import ContainerPlatformClient
33-
from hpecp.exceptions import APIItemNotFoundException
34-
import tempfile
3535
from hpecp.base_resource import ResourceList
36+
from hpecp.exceptions import APIItemNotFoundException
3637

3738
from .base_test import BaseTestCase, MockResponse, mocked_login_post
38-
import six
3939

4040

4141
def mocked_requests_get(*args, **kwargs):

tests/role_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1919
# OTHER DEALINGS IN THE SOFTWARE.
2020

21+
import json
2122
from unittest import TestCase
2223

23-
import json
2424
import requests
2525
import six
2626
from mock import patch
2727

2828
from hpecp import ContainerPlatformClient
29+
2930
from .base_test import BaseTestCase
3031

3132

tests/user_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
from unittest import TestCase
2222

2323
import requests
24+
import six
2425
from mock import patch
2526

2627
from hpecp import ContainerPlatformClient
2728
from hpecp.exceptions import APIItemNotFoundException
2829

29-
from .base_test import MockResponse, BaseTestCase, mocked_login_post
30-
import six
30+
from .base_test import BaseTestCase, MockResponse, mocked_login_post
3131

3232

3333
def get_client():

0 commit comments

Comments
 (0)