Beispiel #1
0
def main(automation_path: str, verbosity: int):
    """
    Yet another home automation service.
    """
    init_logging(verbosity)
    logger.info('Starting My IoT…')
    automation = import_automation(Path(automation_path))
    db = Connection('db.sqlite3', **DATABASE_OPTIONS)
    web.start(Context(db=db, automation=automation), on_startup, on_cleanup)
    logger.info('My IoT stopped.')
Beispiel #2
0
def test_len(connection: Connection):
    assert len(connection) == 0
    connection.get('collection')
    assert len(connection) == 1
    connection.get('collection')
    assert len(connection) == 1
Beispiel #3
0
def test_close(connection: Connection):
    connection.close()
    with raises(ProgrammingError):
        _ = connection['foo']
Beispiel #4
0
def test_getitem_value_error(connection: Connection, name: str):
    with raises(ValueError):
        connection.get(name)
Beispiel #5
0
def test_getitem(connection: Connection, name: str):
    connection.get(name)
Beispiel #6
0
def test_delitem(connection: Connection, name: str):
    connection.get(name)
    del connection[name]
    assert not list(connection)
Beispiel #7
0
def test_iter(connection: Connection):
    assert list(connection) == []
    connection.get('collection')
    assert list(connection) == ['collection']
Beispiel #8
0
async def db() -> Connection:
    return Connection(':memory:', **DATABASE_OPTIONS)
Beispiel #9
0
def connection() -> Connection:
    return Connection(':memory:')