@@ -14,6 +14,7 @@ def test_adding_listener_with_unknown_event_raises_exception(home):
14
14
async def callback (data ):
15
15
print (data )
16
16
17
+ @pytest .mark .timeout (30 )
17
18
def test_starting_live_feed_with_no_listeners_shows_warning (caplog ):
18
19
account = tibber .Account (tibber .DEMO_TOKEN )
19
20
home = account .homes [0 ]
@@ -22,12 +23,14 @@ def test_starting_live_feed_with_no_listeners_shows_warning(caplog):
22
23
home .start_live_feed (f"tibber.py-tests/{ __version__ } " , exit_condition = lambda data : True )
23
24
assert "The event that was broadcasted has no listeners / callbacks! Nothing was run." in caplog .text
24
25
26
+ @pytest .mark .timeout (30 )
25
27
def test_retrieving_live_measurements ():
26
28
account = tibber .Account (tibber .DEMO_TOKEN )
27
29
home = account .homes [0 ]
28
30
29
31
global callback_was_run
30
32
callback_was_run = False
33
+
31
34
@home .event ("live_measurement" )
32
35
async def callback (data ):
33
36
global callback_was_run
@@ -37,31 +40,6 @@ async def callback(data):
37
40
timestamp = timestamp .replace (tzinfo = None )
38
41
now = datetime .now ().replace (tzinfo = None )
39
42
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
65
43
66
44
# Return immediately after the first callback
67
45
home .start_live_feed (f"tibber.py-tests/{ __version__ } " , exit_condition = lambda data : True )
0 commit comments