Skip to content

Commit

Permalink
test: remove a lot of unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
BeatsuDev committed Sep 5, 2024
1 parent fdd154d commit ef90f22
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions tests/realtime/test_live_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def test_adding_listener_with_unknown_event_raises_exception(home):
async def callback(data):
print(data)

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

@pytest.mark.timeout(30)
def test_retrieving_live_measurements():
account = tibber.Account(tibber.DEMO_TOKEN)
home = account.homes[0]

global callback_was_run
callback_was_run = False

@home.event("live_measurement")
async def callback(data):
global callback_was_run
Expand All @@ -37,31 +40,6 @@ async def callback(data):
timestamp = timestamp.replace(tzinfo=None)
now = datetime.now().replace(tzinfo=None)
assert timestamp > now - timedelta(seconds=30)
assert data.power > 0
assert data.last_meter_consumption > 0
assert data.accumulated_consumption > 0
assert isinstance(data.accumulated_production, (int, float))
assert data.accumulated_consumption_last_hour > 0
assert isinstance(data.accumulated_production_last_hour, (int, float))
assert data.accumulated_cost > 0
assert isinstance(data.accumulated_reward, (int, float))
assert data.currency == "SEK"
assert data.min_power >= 0
assert data.max_power > 0
assert data.average_power > 0
assert isinstance(data.power_production, (int, float))
assert isinstance(data.power_reactive, (int, float))
assert data.power_production_reactive > 0
assert isinstance(data.min_power_production, (int, float))
assert isinstance(data.max_power_production, (int, float))
assert data.last_meter_production > 0
assert data.power_factor > 0
assert data.voltage_phase_1 > 0
assert data.voltage_phase_2 > 0
assert data.voltage_phase_3 > 0
assert data.currentL1 > 0
assert data.currentL2 > 0
assert data.currentL3 > 0

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

0 comments on commit ef90f22

Please sign in to comment.