Skip to content

Commit ce7d9e5

Browse files
committed
Sonarcloud smell resolves continued for Anna (and indenting for exc)
1 parent 98ac1a8 commit ce7d9e5

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

tests/test_anna.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from .test_init import _LOGGER, TestPlugwise, pw_exceptions
66

77
SMILE_TYPE = "anna"
8+
# Reoccuring constants
9+
THERMOSTAT_SCHEDULE = "Thermostat schedule"
810

911

1012
class TestPlugwiseAnna(TestPlugwise): # pylint: disable=attribute-defined-outside-init
@@ -30,7 +32,7 @@ async def test_connect_legacy_anna(self):
3032
assert smile.gateway_id == "0000aaaa0000aaaa0000aaaa0000aa00"
3133
assert (
3234
smile._last_active["0000aaaa0000aaaa0000aaaa0000aa00"]
33-
== "Thermostat schedule"
35+
== THERMOSTAT_SCHEDULE
3436
)
3537
assert smile.device_items == 44
3638
assert not self.notifications
@@ -39,7 +41,7 @@ async def test_connect_legacy_anna(self):
3941
smile,
4042
"0000aaaa0000aaaa0000aaaa0000aa00",
4143
good_schedules=[
42-
"Thermostat schedule",
44+
THERMOSTAT_SCHEDULE,
4345
],
4446
)
4547
assert result
@@ -52,7 +54,7 @@ async def test_connect_legacy_anna(self):
5254
smile,
5355
"0000aaaa0000aaaa0000aaaa0000aa00",
5456
good_schedules=[
55-
"Thermostat schedule",
57+
THERMOSTAT_SCHEDULE,
5658
],
5759
unhappy=True,
5860
)
@@ -83,7 +85,7 @@ async def test_connect_legacy_anna_2(self):
8385
assert smile.gateway_id == "be81e3f8275b4129852c4d8d550ae2eb"
8486
assert (
8587
smile._last_active["be81e3f8275b4129852c4d8d550ae2eb"]
86-
== "Thermostat schedule"
88+
== THERMOSTAT_SCHEDULE
8789
)
8890
assert smile.device_items == 44
8991
assert not self.notifications
@@ -92,26 +94,26 @@ async def test_connect_legacy_anna_2(self):
9294
smile,
9395
"be81e3f8275b4129852c4d8d550ae2eb",
9496
good_schedules=[
95-
"Thermostat schedule",
97+
THERMOSTAT_SCHEDULE,
9698
],
9799
)
98100
assert result
99101

100102
smile._schedule_old_states["be81e3f8275b4129852c4d8d550ae2eb"][
101-
"Thermostat schedule"
103+
THERMOSTAT_SCHEDULE
102104
] = "off"
103105
result_1 = await self.tinker_thermostat_schedule(
104106
smile,
105107
"be81e3f8275b4129852c4d8d550ae2eb",
106108
"on",
107-
good_schedules=["Thermostat schedule"],
109+
good_schedules=[THERMOSTAT_SCHEDULE],
108110
single=True,
109111
)
110112
result_2 = await self.tinker_thermostat_schedule(
111113
smile,
112114
"be81e3f8275b4129852c4d8d550ae2eb",
113115
"on",
114-
good_schedules=["Thermostat schedule"],
116+
good_schedules=[THERMOSTAT_SCHEDULE],
115117
single=True,
116118
)
117119
assert result_1 and result_2
@@ -311,7 +313,7 @@ async def test_connect_anna_heatpump_heating(self):
311313
"standaard",
312314
],
313315
)
314-
_LOGGER.debug("ERROR raised: %s", exc.value)
316+
_LOGGER.debug("ERROR raised: %s", exc.value)
315317

316318
# Now change some data and change directory reading xml from
317319
# emulating reading newer dataset after an update_interval,
@@ -365,7 +367,7 @@ async def test_connect_anna_heatpump_cooling(self):
365367
"standaard",
366368
],
367369
)
368-
_LOGGER.debug("ERROR raised: %s", exc.value)
370+
_LOGGER.debug("ERROR raised: %s", exc.value)
369371

370372
await smile.close_connection()
371373
await self.disconnect(server, client)
@@ -420,7 +422,7 @@ async def test_connect_anna_elga_2(self):
420422
await self.device_test(smile, "2022-03-13 00:00:01", testdata)
421423
assert (
422424
smile._last_active["d3ce834534114348be628b61b26d9220"]
423-
== "Thermostat schedule"
425+
== THERMOSTAT_SCHEDULE
424426
)
425427
assert smile.device_items == 62
426428
assert smile.gateway_id == "fb49af122f6e4b0f91267e1cf7666d6f"
@@ -443,7 +445,7 @@ async def test_connect_anna_elga_2_schedule_off(self):
443445
await self.device_test(smile, "2022-03-13 00:00:01", testdata)
444446
assert (
445447
smile._last_active["d3ce834534114348be628b61b26d9220"]
446-
== "Thermostat schedule"
448+
== THERMOSTAT_SCHEDULE
447449
)
448450
assert smile._cooling_present
449451
assert not smile._cooling_enabled
@@ -475,7 +477,7 @@ async def test_connect_anna_elga_2_cooling(self):
475477
await self.device_test(smile, "2022-03-10 00:00:01", testdata)
476478
assert (
477479
smile._last_active["d3ce834534114348be628b61b26d9220"]
478-
== "Thermostat schedule"
480+
== THERMOSTAT_SCHEDULE
479481
)
480482
assert smile.device_items == 62
481483
assert not self.notifications
@@ -524,15 +526,15 @@ async def test_connect_anna_loria_heating_idle(self):
524526
"Winter",
525527
],
526528
)
527-
_LOGGER.debug("ERROR raised: %s", exc.value)
529+
_LOGGER.debug("ERROR raised: %s", exc.value)
528530

529531
with pytest.raises(pw_exceptions.PlugwiseError) as exc:
530532
await self.tinker_thermostat_temp(
531533
smile,
532534
"15da035090b847e7a21f93e08c015ebc",
533535
block_cooling=True,
534536
)
535-
_LOGGER.debug("ERROR raised: %s", exc.value)
537+
_LOGGER.debug("ERROR raised: %s", exc.value)
536538

537539
await self.tinker_dhw_mode(smile)
538540

0 commit comments

Comments
 (0)