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.')
def test_len(connection: Connection): assert len(connection) == 0 connection.get('collection') assert len(connection) == 1 connection.get('collection') assert len(connection) == 1
def test_close(connection: Connection): connection.close() with raises(ProgrammingError): _ = connection['foo']
def test_getitem_value_error(connection: Connection, name: str): with raises(ValueError): connection.get(name)
def test_getitem(connection: Connection, name: str): connection.get(name)
def test_delitem(connection: Connection, name: str): connection.get(name) del connection[name] assert not list(connection)
def test_iter(connection: Connection): assert list(connection) == [] connection.get('collection') assert list(connection) == ['collection']
async def db() -> Connection: return Connection(':memory:', **DATABASE_OPTIONS)
def connection() -> Connection: return Connection(':memory:')