Skip to content

Commit 6aaa6a4

Browse files
committed
test: remove a lot of unnecessary checks
1 parent ee0de31 commit 6aaa6a4

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

Diff for: tests/realtime/test_live_measurements.py

+3-25
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def test_adding_listener_with_unknown_event_raises_exception(home):
1414
async def callback(data):
1515
print(data)
1616

17+
@pytest.mark.timeout(30)
1718
def test_starting_live_feed_with_no_listeners_shows_warning(caplog):
1819
account = tibber.Account(tibber.DEMO_TOKEN)
1920
home = account.homes[0]
@@ -22,12 +23,14 @@ def test_starting_live_feed_with_no_listeners_shows_warning(caplog):
2223
home.start_live_feed(f"tibber.py-tests/{__version__}", exit_condition = lambda data: True)
2324
assert "The event that was broadcasted has no listeners / callbacks! Nothing was run." in caplog.text
2425

26+
@pytest.mark.timeout(30)
2527
def test_retrieving_live_measurements():
2628
account = tibber.Account(tibber.DEMO_TOKEN)
2729
home = account.homes[0]
2830

2931
global callback_was_run
3032
callback_was_run = False
33+
3134
@home.event("live_measurement")
3235
async def callback(data):
3336
global callback_was_run
@@ -37,31 +40,6 @@ async def callback(data):
3740
timestamp = timestamp.replace(tzinfo=None)
3841
now = datetime.now().replace(tzinfo=None)
3942
assert timestamp > now - timedelta(seconds=30)
40-
assert data.power > 0
41-
assert data.last_meter_consumption > 0
42-
assert data.accumulated_consumption > 0
43-
assert isinstance(data.accumulated_production, (int, float))
44-
assert data.accumulated_consumption_last_hour > 0
45-
assert isinstance(data.accumulated_production_last_hour, (int, float))
46-
assert data.accumulated_cost > 0
47-
assert isinstance(data.accumulated_reward, (int, float))
48-
assert data.currency == "SEK"
49-
assert data.min_power >= 0
50-
assert data.max_power > 0
51-
assert data.average_power > 0
52-
assert isinstance(data.power_production, (int, float))
53-
assert isinstance(data.power_reactive, (int, float))
54-
assert data.power_production_reactive > 0
55-
assert isinstance(data.min_power_production, (int, float))
56-
assert isinstance(data.max_power_production, (int, float))
57-
assert data.last_meter_production > 0
58-
assert data.power_factor > 0
59-
assert data.voltage_phase_1 > 0
60-
assert data.voltage_phase_2 > 0
61-
assert data.voltage_phase_3 > 0
62-
assert data.currentL1 > 0
63-
assert data.currentL2 > 0
64-
assert data.currentL3 > 0
6543

6644
# Return immediately after the first callback
6745
home.start_live_feed(f"tibber.py-tests/{__version__}", exit_condition = lambda data: True)

0 commit comments

Comments
 (0)