def fill_database(connection): users = data.users() for user in users: insert_user(connection, user) tasks = data.tasks() for task in tasks: insert_task(connection, task)
def test_users_and_insert_user(): connection = model.connect(":memory:") model.create_database(connection) users = data.users() model.insert_user(connection, users[1]) model.insert_user(connection, users[0]) assert model.users(connection) == [users[0], users[1]]
def test_tasks_and_insert_task(): connection = model.connect(":memory:") model.create_database(connection) tasks = data.tasks() users = data.users() model.insert_user(connection, users[0]) model.insert_user(connection, users[1]) model.insert_task(connection, tasks[6]) model.insert_task(connection, tasks[1]) model.insert_task(connection, tasks[5]) assert model.tasks(connection) == [tasks[1], tasks[5], tasks[6]]
def test_user(): connection = model.connect(":memory:") model.create_database(connection) model.fill_database(connection) for user in data.users(): assert model.user(connection, user['id']) == user
def test_fill_database(): connection = model.connect(":memory:") model.create_database(connection) model.fill_database(connection) assert model.users(connection) == data.users() assert model.tasks(connection) == data.tasks()