Skip to content

Commit 1a496f8

Browse files
committed
Different way of patching
1 parent f33c945 commit 1a496f8

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/murfey/server/ispyb.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def do_insert_data_collection_group(
124124
**kwargs,
125125
):
126126
try:
127-
print(ISPyBSession())
128127
with ISPyBSession() as db:
129128
db.add(record)
130129
db.commit()

tests/server/test_ispyb.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ def test_get_all_ongoing_visits():
7272

7373

7474
@mock.patch("workflows.transport.pika_transport.PikaTransport")
75-
def test_update_data_collection_group(mock_transport, ispyb_db_session: Session):
75+
@mock.patch("murfey.server.ispyb.ISPyBSession.__call__")
76+
def test_update_data_collection_group(
77+
mock_ispyb_session_call, mock_transport, ispyb_db_session: Session
78+
):
79+
mock_ispyb_session_call.return_value = ispyb_db_session
80+
7681
# Manually get the BLSession ID for comparison
7782
bl_session_id = (
7883
ispyb_db_session.execute(
@@ -99,10 +104,9 @@ def test_update_data_collection_group(mock_transport, ispyb_db_session: Session)
99104
)
100105

101106
transport_manager = TransportManager("PikaTransport")
102-
with mock.patch("murfey.server.ispyb.ISPyBSession.__call__", ispyb_db_session):
103-
transport_manager.do_update_data_collection_group(
104-
record=DataCollectionGroup(dataCollectionGroupId=1, experimentTypeId=2)
105-
)
107+
transport_manager.do_update_data_collection_group(
108+
record=DataCollectionGroup(dataCollectionGroupId=1, experimentTypeId=2)
109+
)
106110

107111
final_dcg_entry = get_or_create_db_entry(
108112
session=ispyb_db_session,

0 commit comments

Comments
 (0)