55from murfey .util .db import DataCollectionGroup , GridSquare
66from murfey .util .models import GridSquareParameters
77from murfey .workflows .spa import flush_spa_preprocess
8- from tests import engine
8+ from tests import murfey_db_engine
99
1010
1111@mock .patch ("murfey.workflows.spa.flush_spa_preprocess._transport_object" )
@@ -18,7 +18,7 @@ def test_register_grid_square_update_add_locations(mock_transport, start_postgre
1818 session_id = 2 ,
1919 tag = "session_tag" ,
2020 )
21- with Session (engine ) as murfey_db :
21+ with Session (murfey_db_engine ) as murfey_db :
2222 murfey_db .add (grid_square )
2323 murfey_db .commit ()
2424
@@ -32,14 +32,14 @@ def test_register_grid_square_update_add_locations(mock_transport, start_postgre
3232 )
3333
3434 # Run the registration
35- with Session (engine ) as murfey_db :
35+ with Session (murfey_db_engine ) as murfey_db :
3636 flush_spa_preprocess .register_grid_square (2 , 101 , new_parameters , murfey_db )
3737
3838 # Check this would have updated ispyb
3939 mock_transport .do_update_grid_square .assert_called_with (1 , new_parameters )
4040
4141 # Confirm the database was updated
42- with Session (engine ) as murfey_db :
42+ with Session (murfey_db_engine ) as murfey_db :
4343 grid_square_final_parameters = murfey_db .exec (select (GridSquare )).one ()
4444 assert grid_square_final_parameters .x_location == new_parameters .x_location
4545 assert grid_square_final_parameters .y_location == new_parameters .y_location
@@ -65,22 +65,22 @@ def test_register_grid_square_update_add_nothing(mock_transport, start_postgres)
6565 x_stage_position = 0.3 ,
6666 y_stage_position = 0.4 ,
6767 )
68- with Session (engine ) as murfey_db :
68+ with Session (murfey_db_engine ) as murfey_db :
6969 murfey_db .add (grid_square )
7070 murfey_db .commit ()
7171
7272 # Parameters to update with
7373 new_parameters = GridSquareParameters (tag = "session_tag" )
7474
7575 # Run the registration
76- with Session (engine ) as murfey_db :
76+ with Session (murfey_db_engine ) as murfey_db :
7777 flush_spa_preprocess .register_grid_square (2 , 101 , new_parameters , murfey_db )
7878
7979 # Check this would have updated ispyb
8080 mock_transport .do_update_grid_square .assert_called_with (1 , new_parameters )
8181
8282 # Confirm the database was not updated
83- with Session (engine ) as murfey_db :
83+ with Session (murfey_db_engine ) as murfey_db :
8484 grid_square_final_parameters = murfey_db .exec (select (GridSquare )).one ()
8585 assert grid_square_final_parameters .x_location == 0.1
8686 assert grid_square_final_parameters .y_location == 0.2
@@ -99,7 +99,7 @@ def test_register_grid_square_insert_with_ispyb(
9999 tag = "session_tag" ,
100100 atlas_id = 90 ,
101101 )
102- with Session (engine ) as murfey_db :
102+ with Session (murfey_db_engine ) as murfey_db :
103103 murfey_db .add (grid_square )
104104 murfey_db .commit ()
105105
@@ -126,14 +126,14 @@ def test_register_grid_square_insert_with_ispyb(
126126 )
127127
128128 # Run the registration
129- with Session (engine ) as murfey_db :
129+ with Session (murfey_db_engine ) as murfey_db :
130130 flush_spa_preprocess .register_grid_square (2 , 101 , new_parameters , murfey_db )
131131
132132 # Check this would have updated ispyb
133133 mock_transport .do_insert_grid_square .assert_called_with (90 , 101 , new_parameters )
134134
135135 # Confirm the database entry was made
136- with Session (engine ) as murfey_db :
136+ with Session (murfey_db_engine ) as murfey_db :
137137 grid_square_final_parameters = murfey_db .exec (select (GridSquare )).one ()
138138 assert grid_square_final_parameters .id == 1
139139 assert grid_square_final_parameters .name == 101
0 commit comments