Ejemplo n.º 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.')
Ejemplo n.º 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
Ejemplo n.º 3
0
def test_close(connection: Connection):
    connection.close()
    with raises(ProgrammingError):
        _ = connection['foo']
Ejemplo n.º 4
0
def test_getitem_value_error(connection: Connection, name: str):
    with raises(ValueError):
        connection.get(name)
Ejemplo n.º 5
0
def test_getitem(connection: Connection, name: str):
    connection.get(name)
Ejemplo n.º 6
0
def test_delitem(connection: Connection, name: str):
    connection.get(name)
    del connection[name]
    assert not list(connection)
Ejemplo n.º 7
0
def test_iter(connection: Connection):
    assert list(connection) == []
    connection.get('collection')
    assert list(connection) == ['collection']
Ejemplo n.º 8
0
async def db() -> Connection:
    return Connection(':memory:', **DATABASE_OPTIONS)
Ejemplo n.º 9
0
def connection() -> Connection:
    return Connection(':memory:')