-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(targets): Deserialize floats as
decimal.Decimal
- Loading branch information
1 parent
5f59f38
commit f1de868
Showing
2 changed files
with
65 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Test IO operations.""" | ||
|
||
from __future__ import annotations | ||
|
||
import decimal | ||
|
||
import pytest | ||
|
||
from singer_sdk.io_base import SingerReader | ||
|
||
|
||
class DummyReader(SingerReader): | ||
def _process_activate_version_message(self, message_dict: dict) -> None: | ||
pass | ||
|
||
def _process_batch_message(self, message_dict: dict) -> None: | ||
pass | ||
|
||
def _process_record_message(self, message_dict: dict) -> None: | ||
pass | ||
|
||
def _process_schema_message(self, message_dict: dict) -> None: | ||
pass | ||
|
||
def _process_state_message(self, message_dict: dict) -> None: | ||
pass | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"line,expected", | ||
[ | ||
pytest.param( | ||
b'{"type": "RECORD", "stream": "users", "record": {"id": 1, "value": 1.23}}', # noqa: E501 | ||
{ | ||
"type": "RECORD", | ||
"stream": "users", | ||
"record": {"id": 1, "value": decimal.Decimal("1.23")}, | ||
}, | ||
id="record", | ||
), | ||
], | ||
) | ||
def test_deserialize(line, expected): | ||
reader = DummyReader() | ||
assert reader.deserialize_json(line) == expected |