diff --git a/tests/aio/test_connector.py b/tests/aio/test_connector.py index 14c9e2d..75f33e2 100644 --- a/tests/aio/test_connector.py +++ b/tests/aio/test_connector.py @@ -1,6 +1,7 @@ """Test async connector.""" -from unittest.mock import Mock, patch +import json +from unittest.mock import Mock, mock_open, patch from urllib.parse import urljoin import pytest @@ -91,7 +92,8 @@ async def test_async_connector_client_session(async_connector: DummyAsyncConnect DummyAsyncConnector.set_rate_limiter(None) other_instance.set_client_session(None) - +@patch("builtins.open", new_callable=mock_open, + read_data=json.dumps({"intake_url": "https://intake.sekoia.io/batch"})) @pytest.mark.asyncio async def test_async_connector_push_single_event( async_connector: DummyAsyncConnector, faker: Faker @@ -116,7 +118,7 @@ async def test_async_connector_push_single_event( single_event_id = faker.uuid4() - request_url = urljoin(async_connector.configuration.intake_server, "batch") + request_url = urljoin("https://intake.sekoia.io", "batch") with aioresponses() as mocked_responses: mocked_responses.post( @@ -155,7 +157,7 @@ async def test_async_connector_push_multiple_events( single_event_id = faker.uuid4() - request_url = urljoin(async_connector.configuration.intake_server, "batch") + request_url = urljoin("https://intake.sekoia.io", "batch") with ( aioresponses() as mocked_responses, @@ -200,7 +202,7 @@ async def test_async_connector_raise_error( stop=stop_after_attempt(1), ) - request_url = urljoin(async_connector.configuration.intake_server, "batch") + request_url = urljoin("https://intake.sekoia.io", "batch") with ( aioresponses() as mocked_responses, diff --git a/tests/connectors/test_connector.py b/tests/connectors/test_connector.py index 5ed868e..14f91aa 100644 --- a/tests/connectors/test_connector.py +++ b/tests/connectors/test_connector.py @@ -1,5 +1,6 @@ +import json import os -from unittest.mock import Mock, PropertyMock, patch +from unittest.mock import Mock, PropertyMock, mock_open, patch import pytest from tenacity import Retrying, stop_after_attempt, wait_none @@ -104,6 +105,8 @@ def test_chunk_events_discard_too_long_message(test_connector): assert test_connector.log.called +@patch("builtins.open", new_callable=mock_open, + read_data=json.dumps({"intake_url": "https://intake.sekoia.io/batch"})) def test_push_event_to_intake_with_2_events(test_connector, mocked_trigger_logs): url = "https://intake.sekoia.io/batch" mocked_trigger_logs.post(url, json={"event_ids": ["001", "002"]})