Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -14,9 +14,11 @@

import requests

from airbyte_cdk.models import FailureType
from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
from airbyte_cdk.sources.declarative.decoders.decoder import Decoder
from airbyte_cdk.sources.declarative.types import Config
from airbyte_cdk.utils.traced_exception import AirbyteTracedException


DATASET_PATH = "rest/3.1/analytics/dataset"
Expand Down Expand Up @@ -191,6 +193,7 @@ def decode(self, response: requests.Response) -> Iterable[Mapping[str, Any]]:
"application/x-jsonlines",
"application/x-jsonl+json",
"application/jsonl",
"application/octet-stream",
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 9e1fe63c-80ad-44fe-8927-10e66c9e209b
dockerImageTag: 0.1.3
dockerImageTag: 0.1.4
dockerRepository: airbyte/source-nexus-datasets
githubIssueLabel: source-nexus-datasets
icon: nexus-datasets.svg
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.

pytest_plugins = ["airbyte_cdk.test.utils.manifest_only_fixtures"]
2,597 changes: 2,597 additions & 0 deletions airbyte-integrations/connectors/source-nexus-datasets/unit_tests/poetry.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[build-system]
requires = [ "poetry-core>=1.0.0",]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "source-nexus-datasets-tests"
version = "0.1.0"
description = "Unit tests for source-nexus-datasets"
authors = ["Airbyte <contact@airbyte.io>"]

[tool.poetry.dependencies]
python = "^3.10,<3.13"
airbyte-cdk = ">=7.0.0,<8.0.0"
pytest = "^8"

[tool.pytest.ini_options]
filterwarnings = [
"ignore:This class is experimental*"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.

import json

import pytest
from requests import Response

from airbyte_cdk.utils.traced_exception import AirbyteTracedException


def _create_response(status_code: int, content: str = "", content_type: str = "application/json") -> Response:
response = Response()
response.status_code = status_code
response._content = content.encode("utf-8")
response.headers["Content-Type"] = content_type
return response


def _create_jsonl_response(records: list[dict]) -> Response:
content = "\n".join(json.dumps(r) for r in records)
return _create_response(200, content, "application/json")


@pytest.mark.parametrize(
"status_code,expected_message_fragment",
[
pytest.param(304, "Dataset is not ready, please contact infor member services", id="http_304_not_ready"),
pytest.param(202, "Dataset is not ready, try again later", id="http_202_not_ready"),
pytest.param(500, "Unexpected status code: 500", id="http_500_unexpected"),
pytest.param(403, "Unexpected status code: 403", id="http_403_unexpected"),
],
)
def test_decode_error_status_raises_traced_exception(components_module, status_code, expected_message_fragment):
"""Verify that non-200 status codes raise AirbyteTracedException instead of NameError."""
FlexibleDecoder = components_module.FlexibleDecoder
decoder = FlexibleDecoder(parameters={})
response = _create_response(status_code, content="error body")

with pytest.raises(AirbyteTracedException) as exc_info:
list(decoder.decode(response))
assert expected_message_fragment in exc_info.value.message


def test_decode_success_yields_records(components_module):
"""Verify that a 200 response with JSONL content is decoded correctly."""
FlexibleDecoder = components_module.FlexibleDecoder
decoder = FlexibleDecoder(parameters={})
records = [{"id": "1", "name": "test"}, {"id": "2", "name": "test2"}]
response = _create_jsonl_response(records)

result = list(decoder.decode(response))

assert len(result) == 2
assert result[0]["raw_data"] == {"id": "1", "name": "test"}
assert result[1]["raw_data"] == {"id": "2", "name": "test2"}
assert "raw_data_string" in result[0]


def test_decode_octet_stream_yields_records(components_module):
"""Verify that application/octet-stream content type is decoded as JSONL."""
FlexibleDecoder = components_module.FlexibleDecoder
decoder = FlexibleDecoder(parameters={})
records = [{"id": "1", "name": "test"}]
content = "\n".join(json.dumps(r) for r in records)
response = _create_response(200, content, "application/octet-stream")

result = list(decoder.decode(response))

assert len(result) == 1
assert result[0]["raw_data"] == {"id": "1", "name": "test"}


def test_decode_unsupported_content_type_raises_value_error(components_module):
"""Verify that an unsupported Content-Type raises ValueError."""
FlexibleDecoder = components_module.FlexibleDecoder
decoder = FlexibleDecoder(parameters={})
response = _create_response(200, content="some text", content_type="text/plain")

with pytest.raises(ValueError, match="Unsupported or unrecognized Content-Type"):
list(decoder.decode(response))
1 change: 1 addition & 0 deletions docs/integrations/sources/nexus-datasets.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Please refer https://developer.infornexus.com/api/authentication-choices/hmac fo

| Version | Date | Pull Request | Subject |
|------------------|-------------------|--------------|----------------|
| 0.1.4 | 2026-04-07 | [76138](https://github.com/airbytehq/airbyte/pull/76138) | Add missing imports for AirbyteTracedException and FailureType in components.py |
| 0.1.3 | 2026-02-17 | [73548](https://github.com/airbytehq/airbyte/pull/73548) | Update dependencies |
| 0.1.2 | 2026-02-10 | [73030](https://github.com/airbytehq/airbyte/pull/73030) | Update dependencies |
| 0.1.1 | 2026-02-03 | [72789](https://github.com/airbytehq/airbyte/pull/72789) | Add missing registryOverrides to metadata.yaml |
Expand Down
Loading