Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StephKll3c committed Mar 26, 2024
1 parent 9df5e5c commit 551f593
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 7 additions & 5 deletions tests/aio/test_connector.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion tests/connectors/test_connector.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"]})
Expand Down

0 comments on commit 551f593

Please sign in to comment.