def test_monitor_ac_usage_turn_off(fake_events, arduino, app): old_event = fake_events.timestamp monitor_ac_usage(1) new_event = Event.last_event() old_event = Event.query.filter(Event.timestamp == old_event).first() assert naturally_equivalent(old_event, new_event) is False assert new_event.event == EventType.off assert new_event.event_description == "AutoOff Timer"
def test_monitor_temperatures(arduino, fake_temperatures): old_temp = fake_temperatures.timestamp monitor_temperatures() old_temp = Temperature.query.filter(Temperature.timestamp == old_temp).first() new_temp = Temperature.latest_temperature() assert naturally_equivalent(old_temp, new_temp) is False assert new_temp.temp == Decimal("33.4200") assert new_temp.humidity == Decimal("46.7400")
def test_monitor_ac_usage_leave_on(fake_events, arduino): old_event = fake_events.timestamp monitor_ac_usage() new_event = Event.last_event() old_event = Event.query.filter(Event.timestamp == old_event).first() assert naturally_equivalent(old_event, new_event) assert new_event.event == EventType.on assert new_event.event_description is None
def test_pk_with(Parent: Type["Parent_"], session: Session) -> None: manager: SqlaManager["Parent_"] = SqlaManager(session) parent = Parent(name="pk_parent") session.add(parent) session.commit() last_id = parent.id_ session.expunge_all() manager.pk_with(Parent, last_id) assert ( last_id == manager.instance().id_ and naturally_equivalent(parent, manager.instance()) and parent is not manager.instance() )
def _assert_not_eq(self, instance: _M) -> None: if naturally_equivalent(self.instance(), instance): raise ValueError("The target Instace is the same one as the origin Instace")