|
5 | 5 | from unittest.mock import AsyncMock, MagicMock, patch, ANY |
6 | 6 | from pathlib import Path |
7 | 7 |
|
8 | | -from pydoll.constants import By, RequestStage, ResourceType, RequestMethod |
| 8 | +from pydoll.protocol.network.types import ResourceType, RequestMethod |
| 9 | +from pydoll.protocol.fetch.types import RequestStage |
| 10 | +from pydoll.constants import By |
9 | 11 | from pydoll.browser.tab import Tab |
10 | 12 | from pydoll.exceptions import ( |
11 | 13 | NoDialogPresent, |
@@ -809,14 +811,13 @@ async def test_expect_file_chooser_with_path_objects(self, tab): |
809 | 811 | @pytest.mark.asyncio |
810 | 812 | async def test_expect_file_chooser_event_handler_single_file(self, tab): |
811 | 813 | """Test the real event_handler function with single file.""" |
812 | | - from pydoll.protocol.dom.types import EventFileChooserOpened |
813 | | - from pydoll.protocol.page.events import PageEvent |
| 814 | + from pydoll.protocol.page.events import FileChooserOpenedEvent, PageEvent |
814 | 815 |
|
815 | 816 | # Mock execute_command to capture the call |
816 | 817 | tab._execute_command = AsyncMock() |
817 | 818 |
|
818 | 819 | # Create mock event data |
819 | | - mock_event: EventFileChooserOpened = { |
| 820 | + mock_event: FileChooserOpenedEvent = { |
820 | 821 | 'method': 'Page.fileChooserOpened', |
821 | 822 | 'params': { |
822 | 823 | 'frameId': 'test-frame-id', |
@@ -855,14 +856,13 @@ async def mock_on(event_name, handler, temporary=False): |
855 | 856 | @pytest.mark.asyncio |
856 | 857 | async def test_expect_file_chooser_event_handler_multiple_files(self, tab): |
857 | 858 | """Test the real event_handler function with multiple files.""" |
858 | | - from pydoll.protocol.dom.types import EventFileChooserOpened |
859 | | - from pydoll.protocol.page.events import PageEvent |
| 859 | + from pydoll.protocol.page.events import FileChooserOpenedEvent, PageEvent |
860 | 860 |
|
861 | 861 | # Mock execute_command to capture the call |
862 | 862 | tab._execute_command = AsyncMock() |
863 | 863 |
|
864 | 864 | # Create mock event data |
865 | | - mock_event: EventFileChooserOpened = { |
| 865 | + mock_event: FileChooserOpenedEvent = { |
866 | 866 | 'method': 'Page.fileChooserOpened', |
867 | 867 | 'params': { |
868 | 868 | 'frameId': 'test-frame-id', |
@@ -900,14 +900,13 @@ async def mock_on(event_name, handler, temporary=False): |
900 | 900 |
|
901 | 901 | async def _test_event_handler_with_files(self, tab, files, expected_files, backend_node_id): |
902 | 902 | """Helper method to test event handler with different file types.""" |
903 | | - from pydoll.protocol.dom.types import EventFileChooserOpened |
904 | | - from pydoll.protocol.page.events import PageEvent |
| 903 | + from pydoll.protocol.page.events import FileChooserOpenedEvent, PageEvent |
905 | 904 |
|
906 | 905 | # Mock execute_command to capture the call |
907 | 906 | tab._execute_command = AsyncMock() |
908 | 907 |
|
909 | 908 | # Create mock event data |
910 | | - mock_event: EventFileChooserOpened = { |
| 909 | + mock_event: FileChooserOpenedEvent = { |
911 | 910 | 'method': 'Page.fileChooserOpened', |
912 | 911 | 'params': { |
913 | 912 | 'frameId': 'test-frame-id', |
@@ -1241,10 +1240,10 @@ async def test_continue_request(self, tab): |
1241 | 1240 | @pytest.mark.asyncio |
1242 | 1241 | async def test_fail_request(self, tab): |
1243 | 1242 | """Test fail_request method.""" |
1244 | | - from pydoll.constants import NetworkErrorReason |
| 1243 | + from pydoll.protocol.network.types import ErrorReason |
1245 | 1244 |
|
1246 | 1245 | request_id = 'test_request_456' |
1247 | | - error_reason = NetworkErrorReason.FAILED |
| 1246 | + error_reason = ErrorReason.FAILED |
1248 | 1247 |
|
1249 | 1248 | await tab.fail_request(request_id, error_reason) |
1250 | 1249 |
|
@@ -1288,7 +1287,7 @@ async def test_fulfill_request(self, tab): |
1288 | 1287 | @pytest.mark.asyncio |
1289 | 1288 | async def test_continue_request_with_all_params(self, tab): |
1290 | 1289 | """Test continue_request with all parameters.""" |
1291 | | - from pydoll.constants import RequestMethod |
| 1290 | + from pydoll.protocol.network.types import RequestMethod |
1292 | 1291 |
|
1293 | 1292 | request_id = 'test_request_456' |
1294 | 1293 | url = 'https://modified-example.com' |
@@ -1339,10 +1338,10 @@ async def test_continue_request_with_different_id(self, tab): |
1339 | 1338 | @pytest.mark.asyncio |
1340 | 1339 | async def test_fail_request_with_different_error(self, tab): |
1341 | 1340 | """Test fail_request with different error reason.""" |
1342 | | - from pydoll.constants import NetworkErrorReason |
| 1341 | + from pydoll.protocol.network.types import ErrorReason |
1343 | 1342 |
|
1344 | 1343 | request_id = 'test_request_error' |
1345 | | - error_reason = NetworkErrorReason.ABORTED |
| 1344 | + error_reason = ErrorReason.ABORTED |
1346 | 1345 |
|
1347 | 1346 | await tab.fail_request(request_id, error_reason) |
1348 | 1347 |
|
|
0 commit comments