Skip to content

Commit

Permalink
chore: add spec, validate and discover test connector (#202)
Browse files Browse the repository at this point in the history
* chore: add spec, validate and discover test connector

* chore: add validation in check method

* chore: revert cdk version
  • Loading branch information
am6010 authored Sep 10, 2024
1 parent 5a442aa commit 8631655
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-slim
FROM python:3.9-slim

# Bash is installed for more convenient debugging.
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if __name__ == "__main__":
source = SourceTestConnector()
# make catalog not required for testing
if sys.argv[1] != "discover" and sys.argv.count("--catalog") == 0:
if sys.argv[1] == "read" and sys.argv.count("--catalog") == 0:
sys.argv.append('--catalog')
sys.argv.append('dummy.json')
launch(source, sys.argv[1:])
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ConfiguredAirbyteCatalog,
Status,
Type,
SyncMode,
)
from airbyte_cdk.sources import Source
catalog = {
Expand Down Expand Up @@ -60,9 +61,9 @@ def check(self, logger: AirbyteLogger, config: json) -> AirbyteConnectionStatus:
:return: AirbyteConnectionStatus indicating a Success or Failure
"""
try:
# Not Implemented

return AirbyteConnectionStatus(status=Status.SUCCEEDED)
if config.get("read", {}):
return AirbyteConnectionStatus(status=Status.SUCCEEDED)
return AirbyteConnectionStatus(status=Status.FAILED, message="The configuration is not valid")
except Exception as e:
return AirbyteConnectionStatus(status=Status.FAILED, message=f"An exception occurred: {str(e)}")

Expand All @@ -78,7 +79,7 @@ def discover(self, logger: AirbyteLogger, config: json) -> AirbyteCatalog:
}
for i in range(config.get('read', {}).get('resourcesNumber', 0)):
streams.append(AirbyteStream(
name="test_resource_" + str(i), json_schema=json_schema))
name="test_resource_" + str(i), json_schema=json_schema, supported_sync_modes=[SyncMode.full_refresh]))
return AirbyteCatalog(streams=streams)

def read_catalog(self, catalog_path: str) -> ConfiguredAirbyteCatalog:
Expand Down

0 comments on commit 8631655

Please sign in to comment.