Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source Kyriba: Updates CDK, Increases Testing Coverage, Fixes Acceptance Test Config, Adds Expected Records #34545

Merged
merged 23 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4d0b3fb
Updates unit tests for test coverage
pnilan Jan 25, 2024
e2895a2
Updates CDK to latest version
pnilan Jan 25, 2024
ea27dc6
Sets additional properties to true
pnilan Jan 25, 2024
b294c12
Sets additionalProperties to true for all schemas
pnilan Jan 25, 2024
a89a539
Adds error handling for invalid credentials
pnilan Jan 25, 2024
7e8c767
Updates `acceptance-test-config` so tests run properly
pnilan Jan 25, 2024
d171513
Updates python version to 3.10
pnilan Jan 25, 2024
87c0998
Removes redundant sample catalog
pnilan Jan 25, 2024
ce2845c
Adds expected records for all streams
pnilan Jan 25, 2024
56e3437
Removes incremental test bypass
pnilan Jan 26, 2024
0dd0cf3
Updates Kyriba documentation
pnilan Jan 26, 2024
272153a
Bumps version to 0.1.1 for Updating CDK
pnilan Jan 26, 2024
f0cd8c9
Bumps version in metadata
pnilan Jan 26, 2024
2960093
Merge branch 'master' into pnilan/source-kyriba-cdk-update
pnilan Jan 26, 2024
c9ade9d
Updated version in dockerfile, update req python version in README.md
pnilan Jan 26, 2024
8c93b23
Updates config input order
pnilan Jan 26, 2024
b232de2
Migrate base image
pnilan Jan 30, 2024
0122eed
Merge branch 'master' into pnilan/source-kyriba-cdk-update
pnilan Jan 31, 2024
bea1d73
Merge branch 'master' into pnilan/source-kyriba-cdk-update
pnilan Jan 31, 2024
c75f854
Clean up schemas
pnilan Feb 1, 2024
e2caff7
Sets `fail_on_extra_columns` to false
pnilan Feb 1, 2024
58a6f51
Remove unnecessary validation fields from `shared` schema file
pnilan Feb 1, 2024
a7d3104
Set `fails_on_extra_columns` to false. Adds missing fields for `cash_…
pnilan Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions airbyte-integrations/connectors/source-kyriba/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7.11-alpine3.14 as base
FROM python:3.9.11-alpine3.15 as base

# build and load all requirements
FROM base as builder
Expand Down Expand Up @@ -34,5 +34,5 @@ COPY source_kyriba ./source_kyriba
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.name=airbyte/source-kyriba
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-kyriba/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For information about how to use this connector within Airbyte, see [the documen
### Prerequisites
**To iterate on this connector, make sure to complete this prerequisites section.**

#### Minimum Python version required `= 3.7.0`
#### Minimum Python version required `= 3.10.0`

#### Build & Activate Virtual Environment and install dependencies
From this connector directory, create a virtual environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
# See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference)
# for more information about how to configure these tests
connector_image: airbyte/source-kyriba:dev
tests:
acceptance_tests:
spec:
- spec_path: "source_kyriba/spec.json"
tests:
- spec_path: "source_kyriba/spec.json"
connection:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
tests:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
discovery:
- config_path: "secrets/config.json"
tests:
- config_path: "secrets/config.json"
basic_read:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental: # TODO if your connector does not implement incremental sync, remove this block
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
future_state_path: "integration_tests/abnormal_state.json"
tests:
- config_path: "secrets/config.json"
timeout_seconds: 1200
expect_records:
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: no
extra_records: yes
incremental:
tests:
- config_path: "secrets/config.json"
timeout_seconds: 2400
configured_catalog_path: "integration_tests/configured_catalog.json"
future_state:
future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
tests:
- config_path: "secrets/config.json"
timeout_seconds: 2400
configured_catalog_path: "integration_tests/configured_catalog.json"

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 547dc08e-ab51-421d-953b-8f3745201a8c
dockerImageTag: 0.1.0
dockerImageTag: 0.1.1
dockerRepository: airbyte/source-kyriba
githubIssueLabel: source-kyriba
icon: kyriba.svg
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-kyriba/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from setuptools import find_packages, setup

MAIN_REQUIREMENTS = [
"airbyte-cdk~=0.1",
"airbyte-cdk",
]

TEST_REQUIREMENTS = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"type": "object",
"title": "AccountSearchModel",
"description": "Account search",
"$schema": "http://json-schema.org/schema#",
"required": [
"bank",
"branch",
Expand Down Expand Up @@ -454,8 +457,5 @@
"type": ["null", "string"],
"description": "Account ZBA identifier"
}
},
"title": "AccountSearchModel",
"description": "Account search",
"$schema": "http://json-schema.org/schema#"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"type": "object",
"required": ["account", "bankBalance"],
"additionalProperties": true,
"properties": {
"account": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"type": "object",
"required": ["account", "bankBalance"],
"additionalProperties": true,
"properties": {
"account": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"type": "object",
"additionalProperties": true,
"properties": {
"account": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"type": "object",
"additionalProperties": true,
"properties": {
"account": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"type": "object",
"required": ["uuid", "account", "flowAmount", "flowCode", "status"],
"additionalProperties": true,
"properties": {
"uuid": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,15 @@ def gateway_url(self, config: Mapping[str, Any]) -> str:
return f"https://{config['domain']}/gateway"

def check_connection(self, logger, config) -> Tuple[bool, any]:
client = KyribaClient(config["username"], config["password"], self.gateway_url(config))
client.login()
return True, None
try:
client = KyribaClient(config["username"], config["password"], self.gateway_url(config))
artem1205 marked this conversation as resolved.
Show resolved Hide resolved
client.login()
return True, None
except Exception as e:
if isinstance(e, requests.exceptions.HTTPError) and e.response.status_code == 401:
err_message = f"Please check your `username` and `password`. Error: {repr(e)}"
return False, err_message
return False, repr(e)

def streams(self, config: Mapping[str, Any]) -> List[Stream]:
gateway_url = self.gateway_url(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"title": "Kyriba Spec",
"type": "object",
"required": ["domain", "username", "password", "start_date"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"domain": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,72 +6,66 @@
from unittest.mock import MagicMock

import pytest
from source_kyriba.source import CashBalancesStream
from source_kyriba.source import BankBalancesStream

from .test_streams import config


@pytest.fixture
def patch_base_class(mocker):
# Mock abstract methods to enable instantiating abstract class
mocker.patch.object(CashBalancesStream, "primary_key", "test_primary_key")
mocker.patch.object(CashBalancesStream, "__abstractmethods__", set())
mocker.patch.object(BankBalancesStream, "primary_key", "test_primary_key")
mocker.patch.object(BankBalancesStream, "__abstractmethods__", set())


def test_stream_slices(patch_base_class):
stream = CashBalancesStream(**config())
account_uuids = [{"account_uuid": "first"}, {"account_uuid": "second"}]
stream = BankBalancesStream(**config())
account_uuids = [
{"account_uuid": "first"},
{"account_uuid": "second"}
]
stream.get_account_uuids = MagicMock(return_value=account_uuids)
stream.start_date = date(2022, 1, 1)
stream.end_date = date(2022, 3, 1)
stream.end_date = date(2022, 1, 2)
expected = [
{
"account_uuid": "first",
"startDate": "2022-01-01",
"endDate": "2022-02-01",
"date": "2022-01-01",
},
{
"account_uuid": "second",
"startDate": "2022-01-01",
"endDate": "2022-02-01",
"date": "2022-01-01",
},
{
"account_uuid": "first",
"startDate": "2022-02-02",
"endDate": "2022-03-01",
"date": "2022-01-02",
},
{
"account_uuid": "second",
"startDate": "2022-02-02",
"endDate": "2022-03-01",
},
"date": "2022-01-02",
}
]
slices = stream.stream_slices()
assert slices == expected


def test_path(patch_base_class):
stream = CashBalancesStream(**config())
stream = BankBalancesStream(**config())
inputs = {"stream_slice": {"account_uuid": "uuid"}}
path = stream.path(**inputs)
assert path == "cash-balances/accounts/uuid/balances"
assert path == "bank-balances/accounts/uuid/balances"


def test_request_params(patch_base_class):
stream = CashBalancesStream(**config())
stream = BankBalancesStream(**config())
inputs = {
"stream_slice": {"account_uuid": "uuid", "endDate": "2022-02-01", "startDate": "2022-01-01"},
"stream_slice": {"account_uuid": "uuid", "date": "2022-02-01"},
"stream_state": {},
}
stream.intraday = False
stream.balance_type = "END_OF_DAY"
params = stream.request_params(**inputs)
expected = {
"endDate": "2022-02-01",
"startDate": "2022-01-01",
"intraday": False,
"actual": True,
"estimatedForecasts": False,
"confirmedForecasts": False,
"dateType": "VALUE",
"date": inputs["stream_slice"]["date"],
"type": stream.balance_type,
}
assert params == expected
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
"start_date": "2022-01-01",
}

config = {
"username": "username",
"password": "password",
"domain": "demo.kyriba.com",
"start_date": "2022-01-01",
}


def test_check_connection(mocker):
source = SourceKyriba()
KyribaClient.login = MagicMock()
Expand Down
Loading
Loading