-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc7e06d
commit 4d28791
Showing
3 changed files
with
202 additions
and
49 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
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,58 @@ | ||
from dataclasses import asdict | ||
|
||
import pytest | ||
|
||
from singer_sdk.helpers._singer import ( | ||
BaseBatchFileEncoding, | ||
JSONLinesEncoding, | ||
SDKBatchMessage, | ||
SingerMessageType, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"encoding,expected", | ||
[ | ||
(JSONLinesEncoding("gzip"), {"compression": "gzip", "format": "jsonl"}), | ||
(JSONLinesEncoding(), {"compression": None, "format": "jsonl"}), | ||
], | ||
ids=["jsonl-compression-gzip", "jsonl-compression-none"], | ||
) | ||
def test_encoding_as_dict(encoding: BaseBatchFileEncoding, expected: dict) -> None: | ||
"""Test encoding as dict.""" | ||
assert asdict(encoding) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"message,expected", | ||
[ | ||
( | ||
SDKBatchMessage( | ||
stream="test_stream", | ||
encoding=JSONLinesEncoding("gzip"), | ||
manifest=[ | ||
"path/to/file1.jsonl.gz", | ||
"path/to/file2.jsonl.gz", | ||
], | ||
), | ||
{ | ||
"type": SingerMessageType.BATCH, | ||
"stream": "test_stream", | ||
"encoding": {"compression": "gzip", "format": "jsonl"}, | ||
"manifest": [ | ||
"path/to/file1.jsonl.gz", | ||
"path/to/file2.jsonl.gz", | ||
], | ||
}, | ||
) | ||
], | ||
ids=["batch-message-jsonl"], | ||
) | ||
def test_batch_message_as_dict(message, expected): | ||
"""Test batch message as dict.""" | ||
|
||
dumped = message.asdict() | ||
assert dumped == expected | ||
|
||
dumped.pop("type") | ||
assert message.__class__(**dumped) == message |