|
8 | 8 | from unittest.mock import MagicMock, patch
|
9 | 9 |
|
10 | 10 | import httpx
|
11 |
| -from httpx import RequestError |
12 | 11 | import pytest
|
13 | 12 | import requests
|
14 | 13 | from requests_toolbelt import MultipartDecoder
|
@@ -467,8 +466,8 @@ def test_unit_get_split_pdf_cache_tmp_data_dir_uses_dir_from_form_data(mock_path
|
467 | 466 | assert result == str(Path(mock_dir).resolve())
|
468 | 467 |
|
469 | 468 |
|
470 |
| -def test_before_request_raises_request_error_when_pdf_check_fails(): |
471 |
| - """Test that before_request raises RequestError when pdf_utils.check_pdf throws PDFValidationError.""" |
| 469 | +def test_before_request_raises_pdf_validation_error_when_pdf_check_fails(): |
| 470 | + """Test that before_request raises PDFValidationError when pdf_utils.check_pdf throws PDFValidationError.""" |
472 | 471 | hook = SplitPdfHook()
|
473 | 472 |
|
474 | 473 | # Initialize the hook with a mock client
|
@@ -514,13 +513,12 @@ def test_before_request_raises_request_error_when_pdf_check_fails():
|
514 | 513 | mock_check_pdf.side_effect = pdf_utils.PDFValidationError(error_message)
|
515 | 514 | mock_get_base_url.return_value = "http://localhost:8888"
|
516 | 515 |
|
517 |
| - # Call the method under test and verify it raises RequestError |
518 |
| - with pytest.raises(RequestError) as exc_info: |
| 516 | + # Call the method under test and verify it raises PDFValidationError |
| 517 | + with pytest.raises(pdf_utils.PDFValidationError) as exc_info: |
519 | 518 | hook.before_request(mock_hook_ctx, mock_request)
|
520 | 519 |
|
521 |
| - # Verify the exception has the correct message and request object |
| 520 | + # Verify the exception has the correct message |
522 | 521 | assert str(exc_info.value) == error_message
|
523 |
| - assert exc_info.value.request == mock_request |
524 | 522 |
|
525 | 523 | # Verify that the mocked functions were called as expected
|
526 | 524 | mock_get_fields.assert_called_once_with(mock_request)
|
|
0 commit comments