* Added webflow code * Updated readme * Updated README * Added webflow to source_definitions.yaml * Enhanced documentation for the Webflow source connector * Improved webflow source connector instructions * Moved Site ID to before API token in Spec.yaml (for presentation in the UI) * Addressed comments in PR. * Changes to address requests in PR review * Removed version from config * Minor udpate to spec.yaml for clarity * Updated to pass the accept-version as a constant rather than parameter * Updated check_connection to hit the collections API that requires both site id and the authentication token. * Fixed the test_check_connection to use the new check_connection function * Added a streams test for generate_streams * Re-named "autentication" object to "auth" to be more consistent with the way it is created by the CDK * Added in an explict line to instantiante an "auth" object from WebflowTokenAuthenticator, to make it easier to describe in the blog * Fixed a typo in a comment * Renamed some classes to be more intuitive * Renamed class to be more intuitive * Minor change to an internal method name * Made _get_collection_name_to_id_dict staticmethod * Fixed a unit-test error that only appeared when running " python -m pytest -s unit_tests". This was caused by Mocked settings from test_source.py leaking into test_streams.py * format: add double quotes and remove unused import * readme: remove semantic version naming of connector in build commands * Updated spec.yaml * auto-bump connector version * format files * add changelog * update dockerfile * auto-bump connector version Co-authored-by: sajarin <sajarindider@gmail.com> Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com> Co-authored-by: marcosmarxm <marcosmarxm@gmail.com>
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
#
|
|
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
|
|
#
|
|
|
|
from unittest import TestCase
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from source_webflow.source import SourceWebflow
|
|
|
|
|
|
def test_check_connection(mocker):
|
|
source = SourceWebflow()
|
|
fake_info_record = {"collection": "is_mocked"}
|
|
with patch("source_webflow.source.CollectionsList.read_records", MagicMock(return_value=iter([fake_info_record]))):
|
|
logger_mock, config_mock = MagicMock(), MagicMock()
|
|
assert source.check_connection(logger_mock, config_mock) == (True, None)
|
|
logger_mock.info.assert_called_once()
|
|
my_regex = r"Successfully connected.*" + str(fake_info_record)
|
|
TestCase().assertRegex(logger_mock.method_calls[0].args[0], my_regex)
|
|
|
|
|
|
def test_streams(mocker):
|
|
# use the "with" to prevent the patch from impacting other tests
|
|
with patch("source_webflow.source.SourceWebflow.generate_streams", MagicMock(return_value=["This would be a stream"])):
|
|
source = SourceWebflow()
|
|
config_mock = MagicMock()
|
|
streams = source.streams(config_mock)
|
|
assert len(streams) == 1
|