When the query is ambiguous the callback should be invoked.
(self, run_onecite_process)
| 40 | assert result["report"]["total"] >= 1 |
| 41 | |
| 42 | def test_callback_receives_candidates(self, run_onecite_process): |
| 43 | """When the query is ambiguous the callback should be invoked.""" |
| 44 | callback_log = [] |
| 45 | |
| 46 | def _logging_cb(candidates): |
| 47 | callback_log.append(len(candidates)) |
| 48 | return 0 |
| 49 | |
| 50 | # Use the fixture's mock environment but with our own callback. |
| 51 | # We call process_references directly here because the fixture |
| 52 | # hard-codes the callback. |
| 53 | from unittest.mock import patch |
| 54 | from tests.mock_responses import mock_requests_get |
| 55 | |
| 56 | with ( |
| 57 | patch("onecite.pipeline.requests.get", side_effect=mock_requests_get), |
| 58 | patch("onecite.core.requests.get", side_effect=mock_requests_get), |
| 59 | patch("requests.get", side_effect=mock_requests_get), |
| 60 | ): |
| 61 | result = process_references( |
| 62 | input_content="Some ambiguous reference that might trigger callback", |
| 63 | input_type="txt", |
| 64 | template_name="journal_article_full", |
| 65 | output_format="bibtex", |
| 66 | interactive_callback=_logging_cb, |
| 67 | ) |
| 68 | # Callback may or may not fire depending on search results; |
| 69 | # either way the call should not crash. |
| 70 | assert isinstance(result, dict) |
| 71 | |
| 72 | def test_invalid_input_type_raises(self): |
| 73 | with pytest.raises(Exception): |
nothing calls this directly
no test coverage detected