1- from trushell .core .database import _ensure_initialized , get_all_todos , get_db_connection , insert_todo
1+ from trushell .core .database import (
2+ _ensure_initialized ,
3+ get_all_todos ,
4+ get_db_connection ,
5+ insert_todo ,
6+ )
27from trushell .core .models import Todo
38
49
@@ -20,10 +25,7 @@ def test_get_db_connection_returns_fresh_connection(monkeypatch, tmp_path) -> No
2025 conn_two .close ()
2126
2227
23- def test_insert_todo_assigns_sequential_positions (monkeypatch , tmp_path ) -> None :
24- _use_temp_database (monkeypatch , tmp_path )
25-
26- _ensure_initialized ()
28+ def test_insert_todo_assigns_sequential_positions (in_memory_database ) -> None :
2729 insert_todo (Todo (task = "first" , category = "work" ))
2830 insert_todo (Todo (task = "second" , category = "work" ))
2931
@@ -33,20 +35,14 @@ def test_insert_todo_assigns_sequential_positions(monkeypatch, tmp_path) -> None
3335 assert [task .position for task in tasks ] == [0 , 1 ]
3436
3537
36- def test_get_all_todos_works_with_local_connections (monkeypatch , tmp_path ) -> None :
37- _use_temp_database (monkeypatch , tmp_path )
38-
39- _ensure_initialized ()
38+ def test_get_all_todos_works_with_local_connections (in_memory_database ) -> None :
4039 insert_todo (Todo (task = "alpha" , category = "study" ))
4140
4241 assert len (get_all_todos ()) == 1
4342
4443
45- def test_get_all_todos_returns_rows_ordered_by_position (monkeypatch , tmp_path ) -> None :
46- _use_temp_database (monkeypatch , tmp_path )
47-
48- _ensure_initialized ()
49- with get_db_connection () as conn :
44+ def test_get_all_todos_returns_rows_ordered_by_position (in_memory_database ) -> None :
45+ with in_memory_database as conn :
5046 conn .execute (
5147 "INSERT INTO todos VALUES (?, ?, ?, ?, ?, ?)" ,
5248 ("second" , "work" , "" , None , 0 , 1 ),
@@ -62,7 +58,9 @@ def test_get_all_todos_returns_rows_ordered_by_position(monkeypatch, tmp_path) -
6258 assert [task .position for task in tasks ] == [0 , 1 ]
6359
6460
65- def test_ensure_initialized_skips_lock_when_already_initialized (monkeypatch , tmp_path ) -> None :
61+ def test_ensure_initialized_skips_lock_when_already_initialized (
62+ monkeypatch , tmp_path
63+ ) -> None :
6664 _use_temp_database (monkeypatch , tmp_path )
6765 _ensure_initialized ()
6866
0 commit comments