Skip to content

Commit

Permalink
add tests for json parser
Browse files Browse the repository at this point in the history
  • Loading branch information
pnilan committed Dec 11, 2024
1 parent a8a7bb3 commit 254f877
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions unit_tests/sources/declarative/decoders/parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
#
22 changes: 22 additions & 0 deletions unit_tests/sources/declarative/decoders/parsers/test_parsers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
#

import json

import pytest

from airbyte_cdk.sources.declarative.decoders.parsers import JsonParser


@pytest.mark.parametrize(
"raw_data, expected",
[
(json.dumps({"data-type": "string"}), {"data-type": "string"}),
(json.dumps({"data-type": "bytes"}).encode("utf-8"), {"data-type": "bytes"}),
(bytearray(json.dumps({"data-type": "bytearray"}).encode("utf-8")), {"data-type": "bytearray"}),
],
ids=["test_with_str", "test_with_bytes", "test_with_bytearray"]
)
def test_json_parser_with_valid_data(raw_data, expected):
assert next(JsonParser().parse(raw_data)) == expected

0 comments on commit 254f877

Please sign in to comment.