当前位置: 首页>>代码示例>>Python>>正文


Python Event.last_event方法代码示例

本文整理汇总了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
开发者ID:Teddy-Schmitz,项目名称:temperature_admin,代码行数:9,代码来源:test_models.py

示例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
开发者ID:Teddy-Schmitz,项目名称:temperature_admin,代码行数:10,代码来源:test_views.py

示例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"
开发者ID:Teddy-Schmitz,项目名称:temperature_admin,代码行数:11,代码来源:test_tasks.py

示例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
开发者ID:Teddy-Schmitz,项目名称:temperature_admin,代码行数:11,代码来源:test_tasks.py

示例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")
开发者ID:Teddy-Schmitz,项目名称:temperature_admin,代码行数:16,代码来源:tasks.py

示例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)
开发者ID:Teddy-Schmitz,项目名称:temperature_admin,代码行数:5,代码来源:views.py


注:本文中的models.event.Event.last_event方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。