Skip to content

Commit 2083ed5

Browse files
committed
Removed dead patch from test_add_clinical_trials_to_docs (#1056)
1 parent 5f8958f commit 2083ed5

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

tests/test_clinical_trials.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def mock_bucket_client():
3535
yield mock_client
3636

3737

38-
@pytest.fixture
39-
def mock_session():
38+
@pytest.fixture(name="mock_session")
39+
def fixture_mock_session() -> ClientSession:
4040
return AsyncMock(spec=ClientSession)
4141

4242

@@ -93,35 +93,26 @@ def test_format_to_doc_details():
9393

9494

9595
@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))
10499
mock_response.json.return_value = {
105100
"studies": [
106101
{"protocolSection": {"identificationModule": {"nctId": "NCT12345678"}}}
107102
]
108103
}
109104
mock_session.get.return_value.__aenter__.return_value = mock_response
110105

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)
125116

126117

127118
def test_parse_clinical_trial():

0 commit comments

Comments
 (0)