@@ -35,8 +35,8 @@ def mock_bucket_client():
35
35
yield mock_client
36
36
37
37
38
- @pytest .fixture
39
- def mock_session () :
38
+ @pytest .fixture ( name = "mock_session" )
39
+ def fixture_mock_session () -> ClientSession :
40
40
return AsyncMock (spec = ClientSession )
41
41
42
42
@@ -93,35 +93,26 @@ def test_format_to_doc_details():
93
93
94
94
95
95
@pytest .mark .asyncio
96
- async def test_add_clinical_trials_to_docs ():
97
- mock_session = AsyncMock (spec = ClientSession )
98
- mock_docs = Mock (spec = Docs )
99
- mock_docs .aadd_texts = AsyncMock ()
100
- mock_docs .texts = []
101
-
102
- mock_response = AsyncMock ()
103
- mock_response .raise_for_status .return_value = None
96
+ async def test_add_clinical_trials_to_docs (mock_session ) -> None :
97
+ mock_docs = Mock (spec = Docs , aadd_texts = AsyncMock (), texts = [])
98
+ mock_response = AsyncMock (raise_for_status = Mock (return_value = None ))
104
99
mock_response .json .return_value = {
105
100
"studies" : [
106
101
{"protocolSection" : {"identificationModule" : {"nctId" : "NCT12345678" }}}
107
102
]
108
103
}
109
104
mock_session .get .return_value .__aenter__ .return_value = mock_response
110
105
111
- with patch (
112
- "paperqa.sources.clinical_trials.search_retrieve_clinical_trials" ,
113
- return_value = ([SAMPLE_TRIAL_DATA ], 1 ),
114
- ):
115
- await add_clinical_trials_to_docs (
116
- "test query" , mock_docs , Settings (), session = mock_session
117
- )
118
-
119
- assert (
120
- mock_docs .aadd_texts .call_count == 2
121
- ), "One for the metadata and one for the trial"
122
- call_args = mock_docs .aadd_texts .call_args [1 ]
123
- assert "doc" in call_args
124
- assert isinstance (call_args ["doc" ].citation , str )
106
+ await add_clinical_trials_to_docs (
107
+ "test query" , mock_docs , Settings (), session = mock_session
108
+ )
109
+
110
+ assert (
111
+ mock_docs .aadd_texts .call_count == 2
112
+ ), "One for the metadata and one for the trial"
113
+ call_args = mock_docs .aadd_texts .call_args [1 ]
114
+ assert "doc" in call_args
115
+ assert isinstance (call_args ["doc" ].citation , str )
125
116
126
117
127
118
def test_parse_clinical_trial ():
0 commit comments