* bump connector version * Source: MailChimp, New Stream Automations * fix: Schema error fix * Fixes formatting. * fix: Fixed acceptance test schema errors * fix: Update schema, update dockerlabel * refactor: Update docs * refactor: Update DockerVersionTag * fix: Update EOF and configured catalog * fix: Schema, Update docs * fix: Schema on catalog * fix: update DocketVersionTag * fix: schema, update docs, bump docker version * fix: spec, update doc in streams.py * fix: schema compatability for null * update connector version to 0.4.0 * Update Dockerfile * recreate source spec * restore source spec form main * rollback source spec from main * source spec * run gradle config seed * fix schema and remove unused code * fix docs * bump connector seed file versino * auto-bump connector version --------- Co-authored-by: marcosmarxm <marcosmarxm@gmail.com> Co-authored-by: nataly <nataly@airbyte.io> Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com> Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com>
70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
#
|
|
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
#
|
|
|
|
import pytest
|
|
import requests
|
|
from airbyte_cdk.logger import AirbyteLogger
|
|
from source_mailchimp.source import MailChimpAuthenticator, SourceMailchimp
|
|
|
|
logger = AirbyteLogger()
|
|
|
|
|
|
def test_check_connection_ok(requests_mock, config, data_center):
|
|
responses = [
|
|
{"json": [], "status_code": 200},
|
|
]
|
|
requests_mock.register_uri("GET", f"https://{data_center}.api.mailchimp.com/3.0/ping", responses)
|
|
ok, error_msg = SourceMailchimp().check_connection(logger, config=config)
|
|
|
|
assert ok
|
|
assert not error_msg
|
|
|
|
|
|
def test_check_connection_error(requests_mock, config, data_center):
|
|
requests_mock.register_uri("GET", f"https://{data_center}.api.mailchimp.com/3.0/ping", body=requests.ConnectionError())
|
|
ok, error_msg = SourceMailchimp().check_connection(logger, config=config)
|
|
|
|
assert not ok
|
|
assert error_msg
|
|
|
|
|
|
def test_get_server_prefix_ok(requests_mock, access_token, data_center):
|
|
responses = [
|
|
{"json": {"dc": data_center}, "status_code": 200},
|
|
]
|
|
requests_mock.register_uri("GET", "https://login.mailchimp.com/oauth2/metadata", responses)
|
|
assert MailChimpAuthenticator().get_server_prefix(access_token) == data_center
|
|
|
|
|
|
def test_get_server_prefix_exception(requests_mock, access_token, data_center):
|
|
responses = [
|
|
{"json": {}, "status_code": 200},
|
|
{"status_code": 403},
|
|
]
|
|
requests_mock.register_uri("GET", "https://login.mailchimp.com/oauth2/metadata", responses)
|
|
with pytest.raises(Exception):
|
|
MailChimpAuthenticator().get_server_prefix(access_token)
|
|
|
|
|
|
def test_oauth_config(requests_mock, oauth_config, data_center):
|
|
responses = [
|
|
{"json": {"dc": data_center}, "status_code": 200},
|
|
]
|
|
requests_mock.register_uri("GET", "https://login.mailchimp.com/oauth2/metadata", responses)
|
|
assert MailChimpAuthenticator().get_auth(oauth_config)
|
|
|
|
|
|
def test_apikey_config(apikey_config):
|
|
assert MailChimpAuthenticator().get_auth(apikey_config)
|
|
|
|
|
|
def test_wrong_config(wrong_config):
|
|
with pytest.raises(Exception):
|
|
MailChimpAuthenticator().get_auth(wrong_config)
|
|
|
|
|
|
def test_streams_count(config):
|
|
streams = SourceMailchimp().streams(config)
|
|
assert len(streams) == 5
|