Skip to content

Commit ddab006

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 87101de commit ddab006

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

JciHitachi/api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ def from_device_names(
9393
if device_type in cls.supported_device_type:
9494
peripherals[device_name] = cls(result)
9595

96-
assert device_names is None or len(device_names) == len(
97-
peripherals
98-
), "Some of device_names are not available from the API."
96+
assert device_names is None or len(device_names) == len(peripherals), (
97+
"Some of device_names are not available from the API."
98+
)
9999

100100
return peripherals
101101

@@ -688,9 +688,9 @@ def from_device_names(
688688
if device_type in cls.supported_device_type:
689689
things[device_name] = cls(thing)
690690

691-
assert device_names is None or len(device_names) == len(
692-
things
693-
), "Some of device_names are not available from the API."
691+
assert device_names is None or len(device_names) == len(things), (
692+
"Some of device_names are not available from the API."
693+
)
694694

695695
return things
696696

JciHitachi/utility.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ def extract_bytes(v, start, end): # pragma: no cover
111111
Extracted value.
112112
"""
113113

114-
assert start > end and end >= 0, "Starting byte must be greater than ending byte, \
114+
assert start > end and end >= 0, (
115+
"Starting byte must be greater than ending byte, \
115116
and ending byte must be greater than zero : \
116117
{}, {}".format(start, end)
118+
)
117119
return cast_bytes(v >> end * 8, start - end)

tests/test_api.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,21 @@ def fixture_aws_identity():
131131
class TestAWSAPI:
132132
def test_login(self, fixture_aws_mock_api, fixture_aws_identity):
133133
api = fixture_aws_mock_api
134-
with patch(
135-
"JciHitachi.aws_connection.GetUser.get_data"
136-
) as mock_get_data_get_user, patch(
137-
"JciHitachi.aws_connection.GetUser.login"
138-
) as mock_login_get_user, patch(
139-
"JciHitachi.aws_connection.ListSubUser.get_data"
140-
) as mock_get_data_list_subuser, patch(
141-
"JciHitachi.aws_connection.GetAllDevice.get_data"
142-
) as mock_get_data_get_all_device, patch(
143-
"JciHitachi.aws_connection.JciHitachiAWSMqttConnection.connect"
144-
) as mock_connect_mqtt:
134+
with (
135+
patch(
136+
"JciHitachi.aws_connection.GetUser.get_data"
137+
) as mock_get_data_get_user,
138+
patch("JciHitachi.aws_connection.GetUser.login") as mock_login_get_user,
139+
patch(
140+
"JciHitachi.aws_connection.ListSubUser.get_data"
141+
) as mock_get_data_list_subuser,
142+
patch(
143+
"JciHitachi.aws_connection.GetAllDevice.get_data"
144+
) as mock_get_data_get_all_device,
145+
patch(
146+
"JciHitachi.aws_connection.JciHitachiAWSMqttConnection.connect"
147+
) as mock_connect_mqtt,
148+
):
145149
# initialization
146150
aws_tokens = api._aws_tokens
147151
api._aws_tokens = None
@@ -182,11 +186,14 @@ def test_login(self, fixture_aws_mock_api, fixture_aws_identity):
182186

183187
def test_change_password(self, fixture_aws_mock_api):
184188
api = fixture_aws_mock_api
185-
with patch(
186-
"JciHitachi.aws_connection.ChangePassword.get_data"
187-
) as mock_get_data_1, patch(
188-
"JciHitachi.connection.UpdateUserCredential.get_data"
189-
) as mock_get_data_2:
189+
with (
190+
patch(
191+
"JciHitachi.aws_connection.ChangePassword.get_data"
192+
) as mock_get_data_1,
193+
patch(
194+
"JciHitachi.connection.UpdateUserCredential.get_data"
195+
) as mock_get_data_2,
196+
):
190197
mock_get_data_1.return_value = ("OK", "")
191198
mock_get_data_2.return_value = ("OK", "")
192199
api.change_password("new_password")

tests/test_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def test_sanity(self):
1515
for device_type in self.device_types:
1616
for status_name, status_attributes in STATUS_DICT[device_type].items():
1717
# Test if attribute keys are in status attributes.
18-
assert (
19-
len(attribute_keys - set(status_attributes)) == 0
20-
), f"Lack of attribute keys: {status_name} {set(status_attributes)}"
18+
assert len(attribute_keys - set(status_attributes)) == 0, (
19+
f"Lack of attribute keys: {status_name} {set(status_attributes)}"
20+
)
2121
# Test is_numeric and id2str mutual exclusiveness
2222
assert status_attributes["is_numeric"] ^ (
2323
"id2str" in status_attributes

0 commit comments

Comments
 (0)