本文整理汇总了Python中models.event.Event.last_event方法的典型用法代码示例。如果您正苦于以下问题:Python Event.last_event方法的具体用法?Python Event.last_event怎么用?Python Event.last_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.event.Event
的用法示例。
在下文中一共展示了Event.last_event方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_last_event
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import last_event [as 别名]
def test_last_event(fake_events):
fake_event = fake_events
assert Event.last_event() == fake_event
assert len(Event.query.all()) == 3
assert Event.last_on() == fake_event
示例2: test_power_off_failure
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import last_event [as 别名]
def test_power_off_failure(test_client, fake_users, arduino):
auth_string = base64.b64encode('test_user:test_password')
header = {'Authorization': 'Basic ' + auth_string}
resp = test_client.get('/poweroff', headers=header)
event = Event.last_event()
assert resp.status_code == 500
assert event is None
示例3: test_monitor_ac_usage_turn_off
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import last_event [as 别名]
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"
示例4: test_monitor_ac_usage_leave_on
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import last_event [as 别名]
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
示例5: monitor_ac_usage
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import last_event [as 别名]
def monitor_ac_usage(minutes=30):
""" Checks how long AC has been running and shuts it off after max is reached.
:param minutes: How many minutes to let the AC run continuously.
:return:
"""
with app.app_context():
event = Event.last_event()
if event and event.event != EventType.off:
off_time = event.timestamp.replace(minutes=+minutes)
now = arrow.utcnow()
if off_time < now:
if arduino.turn_off():
Event.create_event(EventType.off, "AutoOff Timer")
示例6: send_last_event
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import last_event [as 别名]
def send_last_event():
data = Event.last_event()
return jsonify(results=data.serialize)