1
0
mirror of synced 2026-01-25 19:02:00 -05:00
Files
airbyte/airbyte-integrations/connectors/source-sendgrid/unit_tests/unit_test.py
Marcos Marx dca2256a7c Bump 2022 license version (#13233)
* Bump year in license short to 2022

* remove protocol from cdk
2022-05-26 15:00:42 -03:00

33 lines
1.2 KiB
Python

#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
from unittest.mock import MagicMock
import pytest
import requests
from airbyte_cdk.logger import AirbyteLogger
from source_sendgrid.source import SourceSendgrid
from source_sendgrid.streams import SendgridStream
@pytest.fixture(name="sendgrid_stream")
def sendgrid_stream_fixture(mocker) -> SendgridStream:
# Wipe the internal list of abstract methods to allow instantiating the abstract class without implementing its abstract methods
mocker.patch("source_sendgrid.streams.SendgridStream.__abstractmethods__", set())
# Mypy yells at us because we're init'ing an abstract class
return SendgridStream() # type: ignore
def test_parse_response_gracefully_handles_nulls(mocker, sendgrid_stream: SendgridStream):
response = requests.Response()
mocker.patch.object(response, "json", return_value=None)
mocker.patch.object(response, "request", return_value=MagicMock())
assert [] == list(sendgrid_stream.parse_response(response))
def test_source_wrong_credentials():
source = SourceSendgrid()
status, error = source.check_connection(logger=AirbyteLogger(), config={"apikey": "wrong.api.key123"})
assert not status