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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃帀 Source Recharge: increase unit_test cov, fix schemas #14902

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@
documentationUrl: https://docs.airbyte.io/integrations/sources/recharge
icon: recharge.svg
sourceType: api
releaseStage: alpha
releaseStage: beta
- name: Recurly
sourceDefinitionId: cd42861b-01fc-4658-a8ab-5d11d0510f01
dockerRepository: airbyte/source-recurly
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-recharge/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.5
LABEL io.airbyte.version=0.1.6
LABEL io.airbyte.name=airbyte/source-recharge
6 changes: 3 additions & 3 deletions airbyte-integrations/connectors/source-recharge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ If you are in an IDE, follow your IDE's instructions to activate the virtualenv.

Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
If this is mumbo jumbo to you, don't worry about it, just put your deps in `setup.py` but install using `pip install -r requirements.txt` and everything
should work as you expect.
If this is mumbo jumbo to you, don't worry about it, just put your deps in `setup.py` but install using `pip install -r requirements.txt` and everything should work as you expect.

#### Building via Gradle
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.
Expand Down Expand Up @@ -101,7 +100,8 @@ Customize `acceptance-test-config.yml` file to configure tests. See [Source Acce
If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
To run your integration tests with acceptance tests, from the connector root, run
```
python -m pytest integration_tests -p integration_tests.acceptance
docker build . --no-cache -t airbyte/source-recharge:dev \
&& python -m pytest -p integration_tests.acceptance
```
To run your integration tests with docker

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/streams_with_output_records_catalog.json"
timeout_seconds: 1200
empty_streams: ["collections", "discounts"]
incremental:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/streams_with_output_records_catalog.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@
@pytest.fixture(scope="session", autouse=True)
def connector_setup():
"""This fixture is a placeholder for external resources that acceptance test might require."""
# TODO: setup test dependencies if needed. otherwise remove the TODO comments
yield
# TODO: clean up test dependencies
1 change: 1 addition & 0 deletions airbyte-integrations/connectors/source-recharge/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

TEST_REQUIREMENTS = [
"pytest~=6.1",
"requests-mock",
]

setup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def __init__(self, start_date, **kwargs):
super().__init__(**kwargs)
self._start_date = pendulum.parse(start_date)

@property
def state_checkpoint_interval(self):
return self.limit

def get_updated_state(self, current_stream_state: MutableMapping[str, Any], latest_record: Mapping[str, Any]) -> Mapping[str, Any]:
latest_benchmark = latest_record[self.cursor_field]
if current_stream_state.get(self.cursor_field):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"discount_codes": {
"type": ["null", "array"],
"items": {
"type": "object"
"type": ["null", "object"]
}
},
"email": {
Expand Down Expand Up @@ -214,7 +214,7 @@
"type": ["null", "string"]
},
"shopify_variant_id_not_found": {
"type": ["null", "integer", "string"]
"type": ["null", "integer"]
},
"status": {
"type": ["null", "string"]
Expand All @@ -226,13 +226,34 @@
"type": ["null", "string"]
},
"tax_lines": {
"type": ["null", "string", "number"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"total_discounts": {
"type": ["null", "string"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"total_line_items_price": {
"type": ["null", "string"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"total_price": {
"type": ["null", "string"]
Expand All @@ -241,7 +262,14 @@
"type": ["null", "string"]
},
"total_tax": {
"type": ["null", "string", "number"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"total_weight": {
"type": ["null", "integer"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@
"type": ["null", "string"]
},
"owner_id": {
"type": ["null", "integer", "string"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"owner_resource": {
"type": ["null", "string"]
Expand All @@ -29,7 +36,14 @@
"format": "date-time"
},
"value": {
"type": ["null", "string", "number", "integer"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"value_type": {
"type": ["null", "string"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,42 @@
"type": ["null", "integer"]
},
"address_id": {
"type": ["null", "integer", "string"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"created_at": {
"type": ["null", "string"],
"format": "date-time"
},
"customer_id": {
"type": ["null", "integer", "string"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"next_charge_scheduled_at": {
"type": ["null", "string"],
"format": "date-time"
},
"price": {
"type": ["null", "integer", "string", "number"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"product_title": {
"type": ["null", "string"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"type": ["null", "object"]
},
"price": {
"type": ["null", "string"]
"type": ["null", "number"]
},
"properties": {
"type": ["null", "array"]
Expand All @@ -219,10 +219,24 @@
"type": ["null", "integer"]
},
"shopify_product_id": {
"type": ["null", "string", "integer"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"shopify_variant_id": {
"type": ["null", "string", "integer"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"sku": {
"type": ["null", "string"]
Expand Down Expand Up @@ -343,7 +357,7 @@
"type": ["null", "string"]
},
"subtotal_price": {
"type": ["null", "number", "string"]
"type": ["null", "number"]
},
"tags": {
"type": ["null", "string"]
Expand All @@ -355,19 +369,26 @@
"type": ["null", "string"]
},
"total_discounts": {
"type": ["null", "string"]
"type": ["null", "number"]
},
"total_line_items_price": {
"type": ["null", "string"]
"type": ["null", "number"]
},
"total_price": {
"type": ["null", "string"]
"type": ["null", "number"]
},
"total_refunds": {
"type": ["null", "string"]
},
"total_tax": {
"type": ["null", "number", "string"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
},
"total_weight": {
"type": ["null", "integer"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@
"type": "string"
},
"value": {
"type": ["string", "integer"]
"oneOf": [
{
"type": ["null", "number"]
},
{
"type": ["null", "string"]
}
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ def get_auth_header(self) -> Mapping[str, Any]:

class SourceRecharge(AbstractSource):
def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, any]:
auth = RechargeTokenAuthenticator(token=config["access_token"])
stream = Shop(authenticator=auth)
try:
auth = RechargeTokenAuthenticator(token=config["access_token"])
list(Shop(authenticator=auth).read_records(SyncMode.full_refresh))
return True, None
result = next(stream.read_records(SyncMode.full_refresh))
if stream.name in result.keys():
return True, None
except Exception as error:
return False, f"Unable to connect to Recharge API with the provided credentials - {repr(error)}"

Expand Down
Loading