async def test_connect_to_aiosqlite_db_and_select_items(sql, aiosqlite_conn): queries = load_from_str(sql, "aiosqlite") items1 = await queries.get_list(conn=aiosqlite_conn, flag=False) assert len(items1) == 0 items1 = await queries.get_list(conn=aiosqlite_conn, flag=True) assert len(items1) == 1
def test_connect_to_sqlite_db_and_select_items(sql, sqlite3_conn): queries = load_from_str(sql, "sqlite3") with sqlite3_conn: items1 = queries.get_list(conn=sqlite3_conn, flag=False) assert len(items1) == 0 items1 = queries.get_list(conn=sqlite3_conn, flag=True) assert len(items1) == 1
async def test_connect_to_aiosqlite_db_and_select_items(sql, aiosqlite_conn): queries = load_from_str(sql, "aiosqlite") items1 = await queries.get_list(conn=aiosqlite_conn, flag=False) assert len(items1) == 0 await queries.create_item(conn=aiosqlite_conn, flag=False, revealed=False, title="bsd") items1 = await queries.get_list(conn=aiosqlite_conn, flag=False) assert len(items1) == 1
def test_connect_to_sqlite_db_and_insert_item(sql, sqlite3_conn): queries = load_from_str(sql, "sqlite3") with sqlite3_conn: items1 = queries.get_list(conn=sqlite3_conn, flag=True) assert len(items1) == 1 queries.create_item(conn=sqlite3_conn, flag=True, revealed=False, title="bsd") items1 = queries.get_list(conn=sqlite3_conn, flag=True) assert len(items1) == 2
def test_correct_names_are_made_for_loaded_queries(sql): queries = load_from_str(sql, "psycopg2") assert "get_list" in queries.available assert "get_list_alt" in queries.available
def test_raises_value_error_when_incorrect_backend(sql): with pytest.raises(ValueError): load_from_str(sql, "i-dont-exist")
def test_load_from_str_correct_query_datum_when_no_record_class(sql): queries = load_from_str(sql, "psycopg2") assert isinstance(queries, QueriesContainer) assert len(queries.available) > 0
def test_returns_zero_datum_objects_for_invalid_contents(invalid_sql): queries = load_from_str(invalid_sql, "psycopg2") assert len(queries.available) == 0